diff --git a/Dockerfile b/Dockerfile index 5144037..1b51e45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,110 @@ -# Ultralytics YOLO ๐Ÿš€, AGPL-3.0 license -# Builds ultralytics/ultralytics:latest image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics -# Image is CUDA-optimized for YOLO11 single/multi-GPU training and inference - -# Start FROM PyTorch image https://hub.docker.com/r/pytorch/pytorch or nvcr.io/nvidia/pytorch:23.03-py3 +# ๐Ÿ“ฆ STEP 1: Use NVIDIA's Official PyTorch Image FROM nvcr.io/nvidia/pytorch:23.08-py3 +# ๐Ÿ”ฅ Comes pre-installed with: +# - Ubuntu 22.04 including Python 3.10 +# - NVIDIA CUDAยฎ 12.2.1 +# - NVIDIA cuBLAS 12.2.5.1 +# - NVIDIA cuDNN 8.9.4 +# - NVIDIA NCCL 2.18.3 +# - NVIDIA RAPIDSโ„ข 23.06 +# - Apex +# - rdma-core 39.0 +# - NVIDIA HPC-X 2.15 +# - OpenMPI 4.1.4+ +# - GDRCopy 2.3 +# - TensorBoard 2.9.0 +# - Nsight Compute 2023.2.1.3 +# - Nsight Systems 2023.2.3.1001 +# - NVIDIA TensorRTโ„ข 8.6.1.6 +# - Torch-TensorRT 2.0.0.dev0 +# - NVIDIA DALIยฎ 1.28.0 +# - MAGMA 2.6.2 +# - JupyterLab 2.3.2 including Jupyter-TensorBoard +# - TransformerEngine 0.11.0++3f01b4f +# - PyTorch quantization wheel 2.1.2 +# Saves time & ensures GPU compatibility! + +# ๐Ÿ›  STEP 2: Install Basic Linux Packages RUN apt-get update && \ apt-get install -y --no-install-recommends \ - gcc git zip unzip wget curl htop libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 libsm6 \ + gcc \ + git \ + zip unzip \ + wget curl \ + htop \ + libgl1 \ + libglib2.0-0 \ + libpython3-dev \ + gnupg \ + g++ \ + libusb-1.0-0 \ + libsm6 \ && rm -rf /var/lib/apt/lists/* +# ๐Ÿšฟ Clean-up: Shrinks the image size by removing cached lists -# Security updates -# https://security.snyk.io/vuln/SNYK-UBUNTU1804-OPENSSL-3314796 +# ๐Ÿ” STEP 3: Apply Security Updates for Core Packages RUN apt upgrade --no-install-recommends -y openssl tar +# ๐Ÿšจ Patch critical vulnerabilities in OpenSSL (network encryption) & tar (archives) -# Create working directory +# ๐Ÿ“ STEP 4: Set Working Directory WORKDIR /app +# All following commands will execute in /app inside the container -# Install requirements +# ๐Ÿงช STEP 5: Install Python Requirements COPY requirements.txt . RUN pip install -r requirements.txt +# ๐Ÿ“ฆ Installs YOLOv7 dependencies (torchvision, opencv-python, numpy, etc.) - -# Install OpenCV with CUDA support +# ๐Ÿ“‚ STEP 6: Copy Source Code to the Container COPY . . -RUN rm -rf ./workspace -RUN bash scripts/build_opencv.sh +# โœ… Adds your whole project directory into the container at /app -# Test CUDA and OpenCV support +# ๐Ÿงน Clean Up Pre-existing Workspace (Optional) +RUN rm -rf ./workspace +# ๐Ÿ’ก Ensures the build is fresh & avoids legacy artifacts + +# โš™๏ธ STEP 7: Build OpenCV with CUDA Support +RUN bash scripts/build_opencv.sh +# ๐Ÿš€ This script compiles OpenCV from source with GPU acceleration for video/image ops +# ๐Ÿ˜Ž Perfect for fast inference on large datasets + +# โœ… STEP 8: Run Diagnostic Tests RUN bash scripts/test-cmds.sh -RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt # Recommend for lower specs -# RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7x.pt -# RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-w6.pt # Recommend for train_aux.py training -# RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6.pt -# RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-d6.pt -RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6e.pt # Recommend for high specs \ No newline at end of file +# ๐Ÿงช Verifies: +# - OpenCV is properly installed +# - CUDA is working +# - Everythingโ€™s talking to each other correctly + +# โฌ‡๏ธ STEP 9: Download YOLOv7 Pretrained Models +# โš ๏ธ Choose the one that matches your hardware & use case + +# ๐Ÿƒโ€โ™‚๏ธ Lightweight Model โ€“ Fast AF +RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt +# Use this for: ๐Ÿ”‹ embedded systems, Raspberry Pi, Jetson Nano +# Speed โœ… Accuracy โŒ + +# ๐Ÿง  Balanced Model โ€“ Best for Most +RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7x.pt +# Use this for: ๐Ÿงช general object detection on mid-range GPUs +# Speed โš–๏ธ Accuracy โš–๏ธ + +# ๐Ÿ”ง Training-Ready โ€“ For Custom Datasets +RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-w6.pt +# Use this for: ๐Ÿ‹๏ธโ€โ™‚๏ธ training with `train_aux.py` +# Comes with extra layers for learning better + +# ๐ŸŽฏ Precision Model โ€“ Accuracy First +RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6.pt +# Use this for: ๐Ÿ“ธ detection where precision matters +# Speed โŒ Accuracy โœ…โœ… + +# ๐Ÿงฌ Deep Variant โ€“ Alternate Heavyweight +RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-d6.pt +# Use this if: Youโ€™re experimenting or need d6-specific layers + +# ๐Ÿ‘‘ Elite Model โ€“ Max Accuracy, Max Power +RUN wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6e.pt +# Use this for: ๐Ÿ–ฅ๏ธ high-end workstations, servers +# Speed โŒโŒ Accuracy ๐Ÿ’ฏ + diff --git a/PROJECTS/DATA/2024-05-28_061155_frame_00007.txt b/PROJECTS/DATA/2024-05-28_061155_frame_00007.txt new file mode 100755 index 0000000..ec8621f --- /dev/null +++ b/PROJECTS/DATA/2024-05-28_061155_frame_00007.txt @@ -0,0 +1 @@ +0 0.421296 0.127930 0.057870 0.074219 diff --git a/PROJECTS/DATA/2024-05-28_061155_frame_00008.txt b/PROJECTS/DATA/2024-05-28_061155_frame_00008.txt new file mode 100755 index 0000000..e69de29 diff --git a/PROJECTS/DATA/2024-05-28_061155_frame_00009.txt b/PROJECTS/DATA/2024-05-28_061155_frame_00009.txt new file mode 100755 index 0000000..e69de29 diff --git a/PROJECTS/DATA/2024-05-28_061658_frame_00000.txt b/PROJECTS/DATA/2024-05-28_061658_frame_00000.txt new file mode 100755 index 0000000..91587db --- /dev/null +++ b/PROJECTS/DATA/2024-05-28_061658_frame_00000.txt @@ -0,0 +1 @@ +0 0.451582 0.119141 0.063657 0.078125 diff --git a/PROJECTS/DATA/2024-05-28_061658_frame_00001.txt b/PROJECTS/DATA/2024-05-28_061658_frame_00001.txt new file mode 100755 index 0000000..e69de29 diff --git a/PROJECTS/DATA/2024-05-28_061658_frame_00002.txt b/PROJECTS/DATA/2024-05-28_061658_frame_00002.txt new file mode 100755 index 0000000..e69de29 diff --git a/PROJECTS/DATA/2024-05-28_061658_frame_00003.txt b/PROJECTS/DATA/2024-05-28_061658_frame_00003.txt new file mode 100755 index 0000000..e69de29 diff --git a/PROJECTS/DATA/2024-05-28_061658_frame_00004.txt b/PROJECTS/DATA/2024-05-28_061658_frame_00004.txt new file mode 100755 index 0000000..e69de29 diff --git a/PROJECTS/DATA/2024-05-28_061658_frame_00005.txt b/PROJECTS/DATA/2024-05-28_061658_frame_00005.txt new file mode 100755 index 0000000..1db99f2 --- /dev/null +++ b/PROJECTS/DATA/2024-05-28_061658_frame_00005.txt @@ -0,0 +1 @@ +0 0.427662 0.118408 0.063657 0.084473 diff --git a/PROJECTS/DATA/2024-05-28_061658_frame_00006.txt b/PROJECTS/DATA/2024-05-28_061658_frame_00006.txt new file mode 100755 index 0000000..d2082fe --- /dev/null +++ b/PROJECTS/DATA/2024-05-28_061658_frame_00006.txt @@ -0,0 +1 @@ +0 0.424576 0.117188 0.069059 0.075195 diff --git a/PROJECTS/DATA/2024-05-28_061658_frame_00007.txt b/PROJECTS/DATA/2024-05-28_061658_frame_00007.txt new file mode 100755 index 0000000..e69de29 diff --git a/PROJECTS/DATA/2024-05-28_061658_frame_00008.txt b/PROJECTS/DATA/2024-05-28_061658_frame_00008.txt new file mode 100755 index 0000000..19b10e9 --- /dev/null +++ b/PROJECTS/DATA/2024-05-28_061658_frame_00008.txt @@ -0,0 +1 @@ +0 0.416088 0.120117 0.060571 0.077148 diff --git a/PROJECTS/DATA/2024-05-28_061658_frame_00009.txt b/PROJECTS/DATA/2024-05-28_061658_frame_00009.txt new file mode 100755 index 0000000..205af92 --- /dev/null +++ b/PROJECTS/DATA/2024-05-28_061658_frame_00009.txt @@ -0,0 +1 @@ +0 0.412616 0.120361 0.070602 0.078613 diff --git a/PROJECTS/DATA/2024-05-28_062201_frame_00000.txt b/PROJECTS/DATA/2024-05-28_062201_frame_00000.txt new file mode 100755 index 0000000..99a1981 --- /dev/null +++ b/PROJECTS/DATA/2024-05-28_062201_frame_00000.txt @@ -0,0 +1 @@ +0 0.444059 0.120850 0.067130 0.077637 diff --git a/PROJECTS/DATA/2024-05-28_062201_frame_00001.txt b/PROJECTS/DATA/2024-05-28_062201_frame_00001.txt new file mode 100755 index 0000000..ef5a4ab --- /dev/null +++ b/PROJECTS/DATA/2024-05-28_062201_frame_00001.txt @@ -0,0 +1 @@ +0 0.440008 0.120605 0.060571 0.075195 diff --git a/README.md b/README.md index 71bf794..d9e6331 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,9 @@ Your existing machine to give a gpu capabilities to existing docker containers. If you have trouble about can not see cuda in your existing machine try `privileged` parameter: ```shell -docker run --gpus all --privileged --rm -it barisx/yolov7-cuda-opencv:latest +docker run --gpus all -it --rm --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 --privileged \ +-v /home/grkm/Documents/yolov7-cuda-opencv/PROJECTS/DATA \ +-v /home/grkm/Documents/yolov7-cuda-opencv/PROJECTS/RESULTS \ ``` After you can check it: diff --git a/scripts/test-cmds.sh b/scripts/test-cmds.sh index 0e6175c..ec86dac 100644 --- a/scripts/test-cmds.sh +++ b/scripts/test-cmds.sh @@ -1,4 +1,89 @@ -python -c "import cv2;print(cv2.cuda.getCudaEnabledDeviceCount())" -python3 -c "import cv2;print(cv2.cuda.getCudaEnabledDeviceCount())" -dpkg -l | grep "opencv" -python -c "import torch;print(torch.cuda.is_available())" \ No newline at end of file +#!/bin/bash + +# Title +echo "๐Ÿงช SYSTEM DIAGNOSTIC TEST SCRIPT FOR AI/ML ENVIRONMENT" + +########################## +# Function: Test OpenCV +########################## +test_opencv() { + echo "-------------------Testing OpenCV installation (START)---------------------" + + echo "๐Ÿ“ฆ Checking OpenCV installation and version..." + python3 -c "import cv2; print(f' OpenCV version: {cv2.__version__}')" + + echo "โš™๏ธ Checking OpenCV build flags for CUDA..." + python3 -c "import cv2; print(cv2.getBuildInformation())" | grep "CUDA" + + echo "๐Ÿš€ Checking if OpenCV can access CUDA-enabled GPU..." + python3 -c "import cv2; print(' โœ… CUDA is enabled for OpenCV') if cv2.cuda.getCudaEnabledDeviceCount() else print(' โŒ CUDA is NOT enabled for OpenCV')" + + echo "-------------------Testing OpenCV installation (END)---------------------" + echo "/" +} + +########################## +# Function: Test PyTorch +########################## +test_torch() { + echo "-------------------Testing PyTorch installation (START)---------------------" + + echo "๐Ÿ“ฆ Checking PyTorch installation and version..." + python3 -c "import torch; print(f' Torch version: {torch.__version__}')" + + echo "๐Ÿš€ Checking if PyTorch can access CUDA-enabled GPU..." + python3 -c "import torch; print(' โœ… CUDA is enabled for Torch') if torch.cuda.is_available() else print(' โŒ CUDA is NOT enabled for Torch')" + + echo "-------------------Testing PyTorch installation (END)---------------------" + echo "/" +} + +########################## +# Function: Test NVCC (CUDA Compiler) +########################## +test_nvcc() { + echo "-------------------Testing nvcc installation (START)---------------------" + + echo "๐Ÿ“ฆ Checking nvcc (NVIDIA CUDA Compiler) version..." + output=$(nvcc --version) + + compiler=$(echo "$output" | grep "nvcc:" | cut -d ':' -f2- | sed 's/^/ /') + build_date=$(echo "$output" | grep "Built on" | sed 's/Built on //; s/_/ /g') + cuda_version=$(echo "$output" | grep "Cuda compilation tools" | sed -E 's/.*release ([^,]+), V([0-9\.]+).*/\1 (\2)/') + build_id=$(echo "$output" | grep "Build cuda") + + echo "๐Ÿง  CUDA Compiler Information:" + echo "- Compiler: $compiler" + echo "- CUDA Version: $cuda_version" + echo "- Build Date: $build_date" + echo "- Internal Build ID: $build_id" + + echo "-------------------Testing nvcc installation (END)---------------------" + echo "/" +} + +########################## +# Function: Test NVIDIA-SMI (Driver & GPU) +########################## +test_nvidia_smi() { + echo "-------------------Testing nvidia-smi installation (START)---------------------" + + echo "๐Ÿ–ฅ๏ธ GPU and driver status:" + nvidia-smi + + echo "-------------------Testing nvidia-smi installation (END)---------------------" +} + +########################## +# Main: Run All Tests +########################## +run_all_tests() { + test_opencv + test_torch + test_nvcc + test_nvidia_smi +} + +# Execute +run_all_tests +echo "-------------------All tests completed!---------------------"