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.1 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
  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 YOLOv8 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.3.1-cuda12.1-cudnn8-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. # Downloads to user config dir
  14. ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
  15. https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
  16. /root/.config/Ultralytics/
  17. # Install linux packages
  18. # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package
  19. # libsm6 required by libqxcb to create QT-based windows for visualization; set 'QT_DEBUG_PLUGINS=1' to test in docker
  20. RUN apt-get update && \
  21. apt-get install -y --no-install-recommends \
  22. gcc git zip unzip wget curl htop libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 libsm6 \
  23. && rm -rf /var/lib/apt/lists/*
  24. # Security updates
  25. # https://security.snyk.io/vuln/SNYK-UBUNTU1804-OPENSSL-3314796
  26. RUN apt upgrade --no-install-recommends -y openssl tar
  27. # Create working directory
  28. WORKDIR /ultralytics
  29. # Copy contents and configure git
  30. COPY . .
  31. RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config
  32. ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt .
  33. # Install pip packages
  34. RUN python3 -m pip install --upgrade pip wheel
  35. # Pin TensorRT-cu12==10.1.0 to avoid 10.2.0 bug https://github.com/ultralytics/ultralytics/pull/14239 (note -cu12 must be used)
  36. RUN pip install -e ".[export]" "tensorrt-cu12==10.1.0" "albumentations>=1.4.6" comet pycocotools
  37. # Run exports to AutoInstall packages
  38. # Edge TPU export fails the first time so is run twice here
  39. RUN yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32 || yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32
  40. RUN yolo export model=tmp/yolov8n.pt format=ncnn imgsz=32
  41. # Requires <= Python 3.10, bug with paddlepaddle==2.5.0 https://github.com/PaddlePaddle/X2Paddle/issues/991
  42. RUN pip install "paddlepaddle>=2.6.0" x2paddle
  43. # Fix error: `np.bool` was a deprecated alias for the builtin `bool` segmentation error in Tests
  44. RUN pip install numpy==1.23.5
  45. # Remove extra build files
  46. RUN rm -rf tmp /root/.config/Ultralytics/persistent_cache.json
  47. # Usage Examples -------------------------------------------------------------------------------------------------------
  48. # Build and Push
  49. # t=ultralytics/ultralytics:latest && sudo docker build -f docker/Dockerfile -t $t . && sudo docker push $t
  50. # Pull and Run with access to all GPUs
  51. # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all $t
  52. # Pull and Run with access to GPUs 2 and 3 (inside container CUDA devices will appear as 0 and 1)
  53. # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus '"device=2,3"' $t
  54. # Pull and Run with local directory access
  55. # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all -v "$(pwd)"/shared/datasets:/datasets $t
  56. # Kill all
  57. # sudo docker kill $(sudo docker ps -q)
  58. # Kill all image-based
  59. # sudo docker kill $(sudo docker ps -qa --filter ancestor=ultralytics/ultralytics:latest)
  60. # DockerHub tag update
  61. # t=ultralytics/ultralytics:latest tnew=ultralytics/ultralytics:v6.2 && sudo docker pull $t && sudo docker tag $t $tnew && sudo docker push $tnew
  62. # Clean up
  63. # sudo docker system prune -a --volumes
  64. # Update Ubuntu drivers
  65. # https://www.maketecheasier.com/install-nvidia-drivers-ubuntu/
  66. # DDP test
  67. # python -m torch.distributed.run --nproc_per_node 2 --master_port 1 train.py --epochs 3
  68. # GCP VM from Image
  69. # docker.io/ultralytics/ultralytics:latest
Tip!

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

Comments

Loading...