thomasbrandon / mish-cuda

Mish Activation Function for PyTorch
MIT License
147 stars 67 forks source link

mish_cuda in Dockerfile #17

Closed ManuelPap closed 2 years ago

ManuelPap commented 2 years ago

Hello !

I am new to Dockers and I would like to install mish_cuda with a docker. I pull the image pytorch/pytorch:1.9.0-cuda11.1-cudnn8-runtime which is suitable configuration for my train.py. CUDA version 11.2 is available in host system.

I write in Dockerfile:

FROM pytorch/pytorch:1.9.0-cuda11.1-cudnn8-runtime

RUN python3 -m pip install --no-cache-dir \
        opencv-python==4.5.1.48 \
        torch==1.8.1+cu111 \
        torchvision==0.9.1+cu111 \
        torchaudio==0.8.1 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html \
        pycocotools \
        pillow \
        matplotlib \
        numpy \
        PyYAML \
        tqdm \
        tensorboard

RUN git clone https://github.com/thomasbrandon/mish-cuda
RUN python3 mish-cuda/setup.py

ENTRYPOINT ["python3"]

but I take

Traceback (most recent call last): File "//mish-cuda/setup.py", line 19, in CUDAExtension( File "/usr/local/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 867, in CUDAExtension library_dirs += library_paths(cuda=True) File "/usr/local/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 975, in library_paths if (not os.path.exists(_join_cuda_home(lib_dir)) and File "/usr/local/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1982, in _join_cuda_home raise EnvironmentError('CUDA_HOME environment variable is not set. ' OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.

Where I should define where CUDA_HOME is in the host environment as I use Docker ?

Thank you in advance!

thomasbrandon commented 2 years ago

You'd need the CUDA SDK installed in the docker (it only uses the CUDA drivers from the host, not the SDK and development stuff). As you're using the PyTorch runtime image it doesn't include the SDK. The devel image (pytorch/pytorch:1.9.0-cuda11.1-cudnn8-devel) will include it and so should have the environment variable set. But you're using PyTorch 1.9 which has a native Mish so there's no need for this implementation.