Skip to content

Commit

Permalink
fix torch install on CPU (#112)
Browse files Browse the repository at this point in the history
* fix torch install on CPU
* debug toch install
* fix unbound variable
* debug torch/paddle install
* debug paddle install
* fix paddle resolve
  • Loading branch information
haobibo authored Nov 30, 2024
1 parent 49b0ab3 commit 5da9c34
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ on:

workflow_dispatch: # Allows you to run this workflow manually from the Actions tab


concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
BUILDKIT_PROGRESS: "plain" # Full logs for CI build.
REGISTRY_URL: "docker.io" # docker.io or other target registry URL: where to push images to.
Expand Down Expand Up @@ -77,7 +80,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: source ./tool.sh && build_image py-chem latest docker_core/Dockerfile --build-arg "ARG_PROFILE_PYTHON=datascience,mkl,chem" && push_image
- run: source ./tool.sh && build_image py-chem latest docker_core/Dockerfile --build-arg "ARG_PROFILE_PYTHON=datascience,mkl,chem,torch" && push_image

qpod_py-std:
name: 'py-std'
Expand Down
34 changes: 17 additions & 17 deletions docker_core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ RUN set -eux \
&& ( which java && echo "py4j % Install py4j if Java exists" >> /opt/utils/install_list_PY_datascience.pip || echo "Skip py4j install" ) \
) || echo "Skip Python datascience packages install" ) \
# -----------------------------
&& export CUDA_VER=$(echo ${CUDA_VERSION:-"999"} | cut -c1-4 | sed 's/\.//' ) \
&& export IDX=$( [ -x "$(command -v nvcc)" ] && echo "cu${CUDA_VER:-117}" || echo "cpu" ) \
&& echo "Detected CUDA version=${CUDA_VER} and IDX=${IDX}" \
# -----------------------------
&& echo "Handle tensorflow installation 1.x/2.x, cpu/gpu: https://www.tensorflow.org/install/source#gpu" \
&& ( $(grep -q "tf" <<< "${ARG_PROFILE_PYTHON}") && ( \
V=$($(grep -q "tf1" <<< "${ARG_PROFILE_PYTHON}") && echo "1" || echo "2" ) \
Expand All @@ -74,29 +78,25 @@ RUN set -eux \
# -----------------------------
&& echo "Handle pytorch installation 1.x only, cpu/gpu: https://pytorch.org/get-started/locally/" \
&& ( $(grep -q "torch" <<< "${ARG_PROFILE_PYTHON}") && ( \
CUDA_VER=$(echo "${CUDA_VERSION:0:4}" | sed 's/\.//' ) \
&& echo "If CUDA version < 11.7, install pytorch 1.x, else install pytorch 2.x; if cuda doesn't exist, install pytorch 2.x" \
echo "If CUDA version < 11.7, install pytorch 1.x, else install pytorch 2.x; if cuda doesn't exist, install pytorch 2.x" \
&& export CUDA_VER_TORCH="117" && V=$([[ "${CUDA_VER:-999}" -lt "${CUDA_VER_TORCH}" ]] && echo "torch<2" || echo "torch") \
&& IDX=$( [ -x "$(command -v nvcc)" ] && echo "cu${CUDA_VER:-117}" || echo "cpu" ) \
&& export PIP_FIND_LINKS="https://download.pytorch.org/whl/${IDX}/torch_stable.html ${PIP_FIND_LINKS:-}" \
&& echo "${V}" > /opt/utils/install_list_PY_torch.pip \
&& pip install --no-cache-dir --root-user-action=ignore -U --pre "${V}" torchvision torchaudio --index-url "https://download.pytorch.org/whl/${IDX}" \
) || echo "Skipping pytorch install" ) \
# -----------------------------
&& echo "Handle paddle installation, cpu/gpu: https://www.paddlepaddle.org.cn/" \
&& if $(grep -q "paddle" <<< "${ARG_PROFILE_PYTHON}") ; then \
URL_PYPI_PADDLE="https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html" \
&& export PIP_FIND_LINKS="${URL_PYPI_PADDLE} ${PIP_FIND_LINKS:-}" \
&& CUDA_VER=$(echo "${CUDA_VERSION:0:4}" | sed 's/\.//' ) \
&& ( $(grep -q "paddle" <<< "${ARG_PROFILE_PYTHON}") && ( \
URL_PYPI_PADDLE="https://www.paddlepaddle.org.cn/packages/stable/${IDX}/" \
&& PADDLE=$( [ -x "$(command -v nvcc)" ] && echo "paddlepaddle-gpu" || echo "paddlepaddle") \
&& PADDLE_VER=$(pip index versions ${PADDLE} -f ${URL_PYPI_PADDLE} | grep 'Available' | cut -d ":" -f 2 | tr ', ' '\n' | grep ${CUDA_VER:-'.'} | head -n 1) \
&& V=$(echo ${PADDLE}==${PADDLE_VER}) && echo "to install paddle: ${V}" \
&& echo "${V}" > /opt/utils/install_list_PY_paddle.pip ; \
else \
echo "Skip paddle install" ; \
fi \
# && PADDLE_VER=$(pip index versions ${PADDLE} -f ${URL_PYPI_PADDLE} | grep 'Available' | cut -d ":" -f 2 | tr ', ' '\n' | grep ${CUDA_VER:-'.'} | head -n 1) \
# && V=$(echo ${PADDLE}==${PADDLE_VER}) && echo "to install paddle: ${V}" \
&& pip install --no-cache-dir --root-user-action=ignore -U --pre --index-url ${URL_PYPI_PADDLE} "${PADDLE}" \
) || echo "Skip paddle install" ) \
# -----------------------------
&& echo "PIP_FIND_LINKS=${PIP_FIND_LINKS:-default}" \
&& for profile in $(echo $ARG_PROFILE_PYTHON | tr "," "\n") ; do ( echo "Pip install for ${profile}" ; install_pip "/opt/utils/install_list_PY_${profile}.pip" ; ) ; done \
# && [ "${PIP_FIND_LINKS+set}" != "set" ] && echo "PIP_FIND_LINKS is not set!" || echo "PIP_FIND_LINKS is set to: ${PIP_FIND_LINKS}" \
&& for profile in $(echo $ARG_PROFILE_PYTHON | tr "," "\n") ; do ( \
[ -f "/opt/utils/install_list_PY_${profile}.apt" ] && install_apt "/opt/utils/install_list_PY_${profile}.apt" || echo "apt install skipped for ${profile}" ; \
[ -f "/opt/utils/install_list_PY_${profile}.pip" ] && install_pip "/opt/utils/install_list_PY_${profile}.pip" || echo "pip install skipped for ${profile}" ; \
) ; done \
# -----------------------------
&& if echo "${ARG_PROFILE_GO}" | grep -q "base" ; then \
echo "Installing GO: ${ARG_PROFILE_GO}" && setup_GO ; \
Expand Down
4 changes: 0 additions & 4 deletions docker_core/work/install_list_PY_torch.pip

This file was deleted.

0 comments on commit 5da9c34

Please sign in to comment.