Skip to content

Commit e4ead17

Browse files
author
thr3a
committed
update: cuda python公式から始めることに
1 parent 88a38d4 commit e4ead17

File tree

2 files changed

+8
-47
lines changed

2 files changed

+8
-47
lines changed

cuda12.4-torch/Dockerfile

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
FROM --platform=linux/x86_64 nvcr.io/nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04
1+
FROM --platform=linux/x86_64 python:3.12-slim
22

3-
ARG PYTHON_VERSION=3.12
43
ARG PACKAGES="git curl ca-certificates vim wget unzip build-essential cmake jq"
54

65
ENV DEBIAN_FRONTEND=noninteractive
@@ -12,25 +11,7 @@ ENV UV_PROJECT_ENVIRONMENT="/usr/"
1211

1312
RUN apt-get update && apt-get install -y --no-install-recommends ${PACKAGES}
1413

15-
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
16-
--mount=type=cache,target=/var/lib/apt,sharing=locked <<INSTALL_UBUNTU_PYTHON
17-
fingerprint=F23C5A6CF475977595C89F51BA6932366A755776
18-
repo=deadsnakes
19-
subrepo=ppa
20-
ubuntu_version=$(. /etc/os-release && echo $VERSION_CODENAME)
21-
curl -sS "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x${fingerprint}" > "./${repo}.asc"
22-
cat "./${repo}.asc" | gpg --dearmor -o "/etc/apt/keyrings/${repo}.gpg"
23-
echo "deb [signed-by=/etc/apt/keyrings/${repo}.gpg] http://ppa.launchpad.net/${repo}/${subrepo}/ubuntu ${ubuntu_version} main" | tee -a /etc/apt/sources.list.d/${repo}.list
24-
25-
apt-get update
26-
apt-get install --no-install-recommends -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev
27-
ln -nfs /usr/bin/python${PYTHON_VERSION} /usr/bin/python
28-
ln -nfs /usr/bin/python${PYTHON_VERSION} /usr/bin/python3
29-
curl -sSL https://bootstrap.pypa.io/get-pip.py | python - --break-system-packages
30-
rm -rf /var/lib/apt/lists/*
31-
pip install uv
32-
INSTALL_UBUNTU_PYTHON
33-
34-
RUN pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124
14+
RUN pip install -U pip
15+
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
3516

3617
WORKDIR /app

cuda12.6-torch/Dockerfile

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
FROM --platform=linux/x86_64 nvcr.io/nvidia/cuda:12.6.3-cudnn-devel-ubuntu24.04
1+
FROM --platform=linux/x86_64 python:3.13-slim
22

3-
ARG PYTHON_VERSION=3.13
4-
ARG PACKAGES="git curl ca-certificates vim wget unzip build-essential cmake jq gnupg"
3+
ARG PACKAGES="git curl ca-certificates vim wget unzip build-essential cmake jq"
54

65
ENV DEBIAN_FRONTEND=noninteractive
76
ENV TZ=Asia/Tokyo
@@ -10,28 +9,9 @@ ENV PIP_NO_CACHE_DIR=on
109
ENV PYTHONDONTWRITEBYTECODE=1
1110
ENV UV_PROJECT_ENVIRONMENT="/usr/"
1211

13-
RUN apt-get update
14-
RUN apt-get install -y --no-install-recommends ${PACKAGES}
12+
RUN apt-get update && apt-get install -y --no-install-recommends ${PACKAGES}
1513

16-
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
17-
--mount=type=cache,target=/var/lib/apt,sharing=locked <<INSTALL_UBUNTU_PYTHON
18-
fingerprint=F23C5A6CF475977595C89F51BA6932366A755776
19-
repo=deadsnakes
20-
subrepo=ppa
21-
ubuntu_version=$(. /etc/os-release && echo $VERSION_CODENAME)
22-
curl -sS "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x${fingerprint}" > "./${repo}.asc"
23-
cat "./${repo}.asc" | gpg --dearmor -o "/etc/apt/keyrings/${repo}.gpg"
24-
echo "deb [signed-by=/etc/apt/keyrings/${repo}.gpg] http://ppa.launchpad.net/${repo}/${subrepo}/ubuntu ${ubuntu_version} main" | tee -a /etc/apt/sources.list.d/${repo}.list
25-
26-
apt-get update
27-
apt-get install --no-install-recommends -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev
28-
ln -nfs /usr/bin/python${PYTHON_VERSION} /usr/bin/python
29-
ln -nfs /usr/bin/python${PYTHON_VERSION} /usr/bin/python3
30-
curl -sSL https://bootstrap.pypa.io/get-pip.py | python - --break-system-packages
31-
rm -rf /var/lib/apt/lists/*
32-
pip install uv
33-
INSTALL_UBUNTU_PYTHON
34-
35-
RUN pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
14+
RUN pip install -U pip
15+
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
3616

3717
WORKDIR /app

0 commit comments

Comments
 (0)