質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.40%
PyTorch

PyTorchは、オープンソースのPython向けの機械学習ライブラリ。Facebookの人工知能研究グループが開発を主導しています。強力なGPUサポートを備えたテンソル計算、テープベースの自動微分による柔軟なニューラルネットワークの記述が可能です。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Q&A

解決済

1回答

396閲覧

Docker buildでのエラー

gymgym

総合スコア99

PyTorch

PyTorchは、オープンソースのPython向けの機械学習ライブラリ。Facebookの人工知能研究グループが開発を主導しています。強力なGPUサポートを備えたテンソル計算、テープベースの自動微分による柔軟なニューラルネットワークの記述が可能です。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

0グッド

0クリップ

投稿2024/06/26 08:53

編集2024/06/28 00:20

実現したいこと

https://qiita.com/YuH25/items/58fa7109ac4579780a85
このサイトを参考にDocker + PyTorchの環境を構築したいです。
環境
GPU: NVIDIA RTX A5000 CUDA Version 12.2
ホストOS: Windows 11
Docker: 24.0.7
Dockerのバックエンド: Ubuntu 24.04 (on WSL2)

nvcc
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_May__3_19:00:59_Pacific_Daylight_Time_2022
Cuda compilation tools, release 11.7, V11.7.64
Build cuda_11.7.r11.7/compiler.31294372_0

発生している問題・分からないこと

サイトの3まで完了したのですが、docker buildを実行したらエラーがでます。
私のCUDAは11.7なのでサイトとはバージョンを変えてインストールしました。

該当のソースコード

Dockerfile

1FROM nvcr.io/nvidia/cuda:11.7.1-base-ubuntu22.04 2 3USER root 4 5RUN apt-get update && apt-get install -y python3-pip 6 7RUN python3 -m pip install --upgrade pip \ 8 && python3 -m pip install --no-cache-dir \ 9 torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117 10 11RUN python3 -m pip install --no-cache-dir jupyter 12 13RUN apt-get autoremove -y && \ 14 apt-get clean && \ 15 rm -rf /usr/local/src/*

docker

1Client: 2 Version: 24.0.7 3 Context: default 4 Debug Mode: false 5 Plugins: 6 buildx: Docker Buildx (Docker Inc.) 7 Version: v0.14.1-desktop.1 8 Path: /usr/local/lib/docker/cli-plugins/docker-buildx 9 compose: Docker Compose (Docker Inc.) 10 Version: v2.27.1-desktop.1 11 Path: /usr/local/lib/docker/cli-plugins/docker-compose 12 debug: Get a shell into any image or container (Docker Inc.) 13 Version: 0.0.32 14 Path: /usr/local/lib/docker/cli-plugins/docker-debug 15 dev: Docker Dev Environments (Docker Inc.) 16 Version: v0.1.2 17 Path: /usr/local/lib/docker/cli-plugins/docker-dev 18 extension: Manages Docker extensions (Docker Inc.) 19 Version: v0.2.24 20 Path: /usr/local/lib/docker/cli-plugins/docker-extension 21 feedback: Provide feedback, right in your terminal! (Docker Inc.) 22 Version: v1.0.5 23 Path: /usr/local/lib/docker/cli-plugins/docker-feedback 24 init: Creates Docker-related starter files for your project (Docker Inc.) 25 Version: v1.2.0 26 Path: /usr/local/lib/docker/cli-plugins/docker-init 27 sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.) 28 Version: 0.6.0 29 Path: /usr/local/lib/docker/cli-plugins/docker-sbom 30 scout: Docker Scout (Docker Inc.) 31 Version: v1.9.3 32 Path: /usr/local/lib/docker/cli-plugins/docker-scout 33 34Server: 35 Containers: 0 36 Running: 0 37 Paused: 0 38 Stopped: 0 39 Images: 1 40 Server Version: 24.0.7 41 Storage Driver: overlay2 42 Backing Filesystem: extfs 43 Supports d_type: true 44 Using metacopy: false 45 Native Overlay Diff: true 46 userxattr: false 47 Logging Driver: json-file 48 Cgroup Driver: cgroupfs 49 Cgroup Version: 1 50 Plugins: 51 Volume: local 52 Network: bridge host ipvlan macvlan null overlay 53 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog 54 Swarm: inactive 55 Runtimes: io.containerd.runc.v2 nvidia runc 56 Default Runtime: nvidia 57 Init Binary: docker-init 58 containerd version: 59 runc version: ddeeca392c7bd8b33d0a66400b77af7a97e16cef 60 init version: 61 Security Options: 62 seccomp 63 Profile: builtin 64 Kernel Version: 5.15.153.1-microsoft-standard-WSL2 65 Operating System: Ubuntu 24.04 LTS 66 OSType: linux 67 Architecture: x86_64 68 CPUs: 32 69 Total Memory: 62.62GiB 70 Name: DG173 71 ID: 903859cf-e2da-4627-9bab-e646ae14ed64 72 Docker Root Dir: /var/lib/docker 73 Debug Mode: false 74 Experimental: false 75 Insecure Registries: 76 127.0.0.0/8 77 Live Restore Enabled: false 78 79WARNING: No blkio throttle.read_bps_device support 80WARNING: No blkio throttle.write_bps_device support 81WARNING: No blkio throttle.read_iops_device support 82WARNING: No blkio throttle.write_iops_device support

試したこと・調べたこと

  • teratailやGoogle等で検索した
  • ソースコードを自分なりに変更した
  • 知人に聞いた
  • その他
上記の詳細・結果

下記がbuildを実行したときのエラーとなります。
[+] Building 40.3s (5/8) docker:default
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 464B 0.0s
=> [internal] load metadata for nvcr.io/nvidia/cuda:11.7.1-base-ubuntu22.04 0.0s
=> CACHED [1/5] FROM nvcr.io/nvidia/cuda:11.7.1-base-ubuntu22.04 0.0s
=> ERROR [2/5] RUN apt-get update && apt-get install -y python3-pip 40.0s

[2/5] RUN apt-get update && apt-get install -y python3-pip:

38.35 Err:1 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 InRelease
38.35 Could not connect to developer.download.nvidia.com:443 (152.199.39.144), connection timed out
39.60 Err:2 http://archive.ubuntu.com/ubuntu jammy InRelease
39.60 Could not connect to archive.ubuntu.com:80 (91.189.91.81), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.83), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.82), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.82), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.83), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.81), connection timed out
39.62 Err:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
39.62 Unable to connect to archive.ubuntu.com:80:
39.63 Err:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
39.63 Unable to connect to archive.ubuntu.com:80:
39.82 Err:5 http://security.ubuntu.com/ubuntu jammy-security InRelease
39.82 Could not connect to security.ubuntu.com:80 (185.125.190.81), connection timed out Could not connect to security.ubuntu.com:80 (185.125.190.83), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.81), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.83), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.82), connection timed out Could not connect to security.ubuntu.com:80 (185.125.190.82), connection timed out
39.85 Reading package lists...
39.89 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease Could not connect to archive.ubuntu.com:80 (91.189.91.81), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.83), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.82), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.82), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.83), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.81), connection timed out
39.89 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease Unable to connect to archive.ubuntu.com:80:
39.89 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease Unable to connect to archive.ubuntu.com:80:
39.89 W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease Could not connect to security.ubuntu.com:80 (185.125.190.81), connection timed out Could not connect to security.ubuntu.com:80 (185.125.190.83), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.81), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.83), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.82), connection timed out Could not connect to security.ubuntu.com:80 (185.125.190.82), connection timed out
39.89 W: Failed to fetch https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/InRelease Could not connect to developer.download.nvidia.com:443 (152.199.39.144), connection timed out
39.89 W: Some index files failed to download. They have been ignored, or old ones used instead.
39.91 Reading package lists...
39.94 Building dependency tree...
39.94 Reading state information...
39.94 E: Unable to locate package python3-pip

Dockerfile:5

3 | USER root
4 |
5 | >>> RUN apt-get update && apt-get install -y python3-pip
6 |
7 | RUN python3 -m pip install --upgrade pip \

ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y python3-pip" did not complete successfully: exit code: 100

補足

特になし

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

/bin/sh: 1: sudo: not found

エラーメッセージのとおりです。通常、Docker内にsudoは入っていません。

明示的にUSERで切り替えるまでの構築はrootで進みますので、sudoは不要です。

投稿2024/06/26 09:02

maisumakun

総合スコア145628

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

gymgym

2024/06/26 22:40

ご回答いただきありがとうございます。 sudoを削除して実行したら下記のようなエラーが発生するようになりました。 ------ > [2/5] RUN apt-get update && apt-get install -y python3-pip: 31.30 Ign:1 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 InRelease 32.32 Ign:1 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 InRelease 32.55 Ign:2 http://archive.ubuntu.com/ubuntu jammy InRelease 32.57 Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease 32.58 Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease 32.78 Ign:5 http://security.ubuntu.com/ubuntu jammy-security InRelease 33.57 Ign:2 http://archive.ubuntu.com/ubuntu jammy InRelease 33.58 Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease 33.60 Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease 33.79 Ign:5 http://security.ubuntu.com/ubuntu jammy-security InRelease 34.33 Ign:1 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 InRelease 35.59 Ign:2 http://archive.ubuntu.com/ubuntu jammy InRelease 35.60 Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease 35.62 Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease 35.81 Ign:5 http://security.ubuntu.com/ubuntu jammy-security InRelease 38.35 Err:1 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 InRelease 38.35 Could not connect to developer.download.nvidia.com:443 (152.199.39.144), connection timed out 39.60 Err:2 http://archive.ubuntu.com/ubuntu jammy InRelease 39.60 Could not connect to archive.ubuntu.com:80 (91.189.91.81), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.83), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.82), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.82), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.83), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.81), connection timed out 39.62 Err:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease 39.62 Unable to connect to archive.ubuntu.com:80: 39.63 Err:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease 39.63 Unable to connect to archive.ubuntu.com:80: 39.82 Err:5 http://security.ubuntu.com/ubuntu jammy-security InRelease 39.82 Could not connect to security.ubuntu.com:80 (185.125.190.81), connection timed out Could not connect to security.ubuntu.com:80 (185.125.190.83), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.81), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.83), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.82), connection timed out Could not connect to security.ubuntu.com:80 (185.125.190.82), connection timed out 39.85 Reading package lists... 39.89 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease Could not connect to archive.ubuntu.com:80 (91.189.91.81), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.83), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.82), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.82), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.83), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.81), connection timed out 39.89 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease Unable to connect to archive.ubuntu.com:80: 39.89 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease Unable to connect to archive.ubuntu.com:80: 39.89 W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease Could not connect to security.ubuntu.com:80 (185.125.190.81), connection timed out Could not connect to security.ubuntu.com:80 (185.125.190.83), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.81), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.83), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.82), connection timed out Could not connect to security.ubuntu.com:80 (185.125.190.82), connection timed out 39.89 W: Failed to fetch https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/InRelease Could not connect to developer.download.nvidia.com:443 (152.199.39.144), connection timed out 39.89 W: Some index files failed to download. They have been ignored, or old ones used instead. 39.91 Reading package lists... 39.94 Building dependency tree... 39.94 Reading state information... 39.94 E: Unable to locate package python3-pip ------ Dockerfile:5 -------------------- 3 | USER root 4 | 5 | >>> RUN apt-get update && apt-get install -y python3-pip 6 | 7 | RUN python3 -m pip install --upgrade pip \ -------------------- ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y python3-pip" did not complete successfully: exit code: 100
gymgym

2024/06/26 23:42

Docker Desktopを立ち上げた状態で実行したらうまくいきました。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.40%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問