Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

Dockerfile 4.0 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  1. # Ultralytics YOLO 🚀, AGPL-3.0 license
  2. # Builds ultralytics/ultralytics:latest image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
  3. # Image is CUDA-optimized for YOLO11 single/multi-GPU training and inference
  4. # Start FROM PyTorch image https://hub.docker.com/r/pytorch/pytorch or nvcr.io/nvidia/pytorch:23.03-py3
  5. FROM pytorch/pytorch:2.5.0-cuda12.4-cudnn9-runtime
  6. # Set environment variables
  7. # Avoid DDP error "MKL_THREADING_LAYER=INTEL is incompatible with libgomp.so.1 library" https://github.com/pytorch/pytorch/issues/37377
  8. ENV PYTHONUNBUFFERED=1 \
  9. PYTHONDONTWRITEBYTECODE=1 \
  10. PIP_NO_CACHE_DIR=1 \
  11. PIP_BREAK_SYSTEM_PACKAGES=1 \
  12. MKL_THREADING_LAYER=GNU \
  13. OMP_NUM_THREADS=1
  14. # Downloads to user config dir
  15. ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
  16. https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
  17. /root/.config/Ultralytics/
  18. # Install linux packages
  19. # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package
  20. # libsm6 required by libqxcb to create QT-based windows for visualization; set 'QT_DEBUG_PLUGINS=1' to test in docker
  21. RUN apt-get update && \
  22. apt-get install -y --no-install-recommends \
  23. gcc git zip unzip wget curl htop libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 libsm6 \
  24. && rm -rf /var/lib/apt/lists/*
  25. # Security updates
  26. # https://security.snyk.io/vuln/SNYK-UBUNTU1804-OPENSSL-3314796
  27. RUN apt upgrade --no-install-recommends -y openssl tar
  28. # Create working directory
  29. WORKDIR /ultralytics
  30. # Copy contents and configure git
  31. COPY . .
  32. RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config
  33. ADD https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt .
  34. # Install pip packages
  35. RUN python3 -m pip install --upgrade pip wheel
  36. # Note -cu12 must be used with tensorrt)
  37. RUN pip install -e ".[export]" tensorrt-cu12 "albumentations>=1.4.6" comet pycocotools
  38. # Run exports to AutoInstall packages
  39. # Edge TPU export fails the first time so is run twice here
  40. RUN yolo export model=tmp/yolo11n.pt format=edgetpu imgsz=32 || yolo export model=tmp/yolo11n.pt format=edgetpu imgsz=32
  41. RUN yolo export model=tmp/yolo11n.pt format=ncnn imgsz=32
  42. # Requires <= Python 3.10, bug with paddlepaddle==2.5.0 https://github.com/PaddlePaddle/X2Paddle/issues/991
  43. RUN pip install "paddlepaddle>=2.6.0" x2paddle
  44. # Fix error: `np.bool` was a deprecated alias for the builtin `bool` segmentation error in Tests
  45. RUN pip install numpy==1.23.5
  46. # Remove extra build files
  47. RUN rm -rf tmp /root/.config/Ultralytics/persistent_cache.json
  48. # Usage Examples -------------------------------------------------------------------------------------------------------
  49. # Build and Push
  50. # t=ultralytics/ultralytics:latest && sudo docker build -f docker/Dockerfile -t $t . && sudo docker push $t
  51. # Pull and Run with access to all GPUs
  52. # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all $t
  53. # Pull and Run with access to GPUs 2 and 3 (inside container CUDA devices will appear as 0 and 1)
  54. # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus '"device=2,3"' $t
  55. # Pull and Run with local directory access
  56. # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all -v "$(pwd)"/shared/datasets:/datasets $t
  57. # Kill all
  58. # sudo docker kill $(sudo docker ps -q)
  59. # Kill all image-based
  60. # sudo docker kill $(sudo docker ps -qa --filter ancestor=ultralytics/ultralytics:latest)
  61. # DockerHub tag update
  62. # t=ultralytics/ultralytics:latest tnew=ultralytics/ultralytics:v6.2 && sudo docker pull $t && sudo docker tag $t $tnew && sudo docker push $tnew
  63. # Clean up
  64. # sudo docker system prune -a --volumes
  65. # Update Ubuntu drivers
  66. # https://www.maketecheasier.com/install-nvidia-drivers-ubuntu/
  67. # DDP test
  68. # python -m torch.distributed.run --nproc_per_node 2 --master_port 1 train.py --epochs 3
  69. # GCP VM from Image
  70. # docker.io/ultralytics/ultralytics:latest
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...