Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RuntimeError: Found no NVIDIA driver on your system

I am trying to build a docker image that requires GPU CUDA access. I am using an AWS EC2 p2.xlarge instance that supposedly has the correct hardware. My Dockerfile is building but when running my code, PyTorch can't find CUDA.

print(torch.__version__, torch.cuda.is_available())

returns

1.10.0+cu113 False

This is my Dockerfile

FROM nvidia/cuda:11.2.1-cudnn8-devel-ubuntu18.04

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
    python3-opencv ca-certificates python3-dev git wget sudo ninja-build
RUN ln -sv /usr/bin/python3 /usr/bin/python

# Update apt packages
RUN apt update
RUN apt upgrade -y
RUN apt-get -y install git

# Install pip
RUN apt install python3-pip -y
RUN python -m pip install --upgrade pip

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install opencv-python
RUN pip install --no-cache-dir awscli
RUN pip install opencv-python
RUN pip install wheel
RUN pip install setuptools
RUN pip install pip install nvidia-ml-py3

############ Detectron2 pre-built binaries Pytorch default install ############
RUN pip3 install torch==1.10.0+cu113 torchvision==0.11.1+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
RUN pip install cython

RUN pip install --user 'git+https://github.com/facebookresearch/fvcore'

RUN pip install 'git+https://github.com/facebookresearch/detectron2.git'

ARG magma-cuda112
RUN if [ -z "$MAGMA_CUDA_VERSION" ] ; then \
    echo "Building with CPU support ..."; \
    else \
    echo "Building with GPU/CUDA support ..."; \
    conda install -y -c pytorch ${MAGMA_CUDA_VERSION} && conda clean -ya; \
    fi

# set FORCE_CUDA because during `docker build` cuda is not accessible
ENV FORCE_CUDA="1"
# This will by default build detectron2 for all common cuda architectures and take a lot more time,
# because inside `docker build`, there is no way to tell which architecture will be used.
ARG TORCH_CUDA_ARCH_LIST="3.7+PTX;5.0;6.0;6.1;7.0;7.5;8.0;8.6"
ENV TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST}"

COPY . .
RUN aws s3 cp s3://bucket/file/model.pth ./output
CMD [ "python", "impaction_detection.py" ]

I am trying to build this image using a docker-compose.yml file.

like image 831
James Faure Avatar asked Sep 02 '26 19:09

James Faure


1 Answers

For Google Collab only: Just click on RAM/Disk(this will appear once your notebook is connected) button on the notebook and change the runtime type to t4gpu, this will work and your epoch will run way faster.

like image 85
Kartikey Chawla Avatar answered Sep 04 '26 08:09

Kartikey Chawla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!