harskish / ganspace

Discovering Interpretable GAN Controls [NeurIPS 2020]
Apache License 2.0
1.78k stars 265 forks source link

Pycuda import error #9

Open natoucs-datagen opened 4 years ago

natoucs-datagen commented 4 years ago

Trying to run interactive.py I get this error:

import pycuda.driver
ModuleNotFoundError: No module named 'pycuda'

Is pycuda not installed through the conda environment (.yml) file ?

MineThingIssues commented 4 years ago

You have to install PyCuda yourself, and make sure that when you run configure.py you enable OpenGL, as that is required for this to work. Instructions can be found here: https://wiki.tiker.net/PyCuda/Installation

natoucs-datagen commented 4 years ago

Thanks! I managed to install PyCuda through the pip module inside the conda environment.

anaconda/envs/ganspace/bin/pip install pycuda

However this leads to:

ImportError: PyCUDA was compiled without GL extension support

I am not sure how to add GL extension support with the PyCuda installed through pip. So I will try what you suggested.

natoucs-datagen commented 4 years ago

So I managed to install from your link @MineThingIssues. And I used: python configure.py --cuda-root=/usr/local/cuda --cuda-enable-gl to make sure OpenGL is used. I did all the steps while keeping my conda env active and then I ran and passed all the unittests in the pycuda /test folder. However I still get the same error.

Somebody knows why ?

natoucs-datagen commented 4 years ago

Ok I managed to install PyCuda inside the conda environment, deleted PyCuda files from the previous pip install there and succesfully ran interactive.py.

natoucs-datagen commented 4 years ago

Actually now that I have solved some other bugs which where blocking execution and not related to PyCuda, I get:

RuntimeError: make_default_context() wasn't able to create a context on any of the 2 detected devices

This is when running interactive.py. System details: 2 GPUs GeForce RTX NVIDIA-SMI 440.64.00 | Driver Version: 440.64.00 | CUDA Version: 10.2 CentOS Linux 8

Anybody went through this and was able to solve it ?

martindisley commented 4 years ago

I'm having also having some trouble installing PYCUDA correctly.

I followed instructions from @MineThingIssues + @natoucs-datagen above. cd pycuda-2019.1.2/ python configure.py --cuda-root=/usr/local/cuda --cuda-enable-gl sudo su -c 'make install

It seemed to install correctly (no errors), but I'm still getting this:

Traceback (most recent call last):
  File "interactive.py", line 26, in <module>
    from TkTorchWindow import TorchImageView
  File "/home/martin/workspace/ganspace/TkTorchWindow.py", line 16, in <module>
    from pycuda.gl import graphics_map_flags
  File "/home/martin/anaconda3/envs/ganspace/lib/python3.7/site-packages/pycuda/gl/__init__.py", line 5, in <module>
    raise ImportError("PyCUDA was compiled without GL extension support")
ImportError: PyCUDA was compiled without GL extension support

I previously installed PYCUDA via conda (because su -c "make install" failed for me unless I ran it sudo). Is it possible that it's getting confused between the two versions installed? i.e do I have to remove the env and repo and start again?

DarkGeekMS commented 3 years ago

In case you still have the same issue :

This works for me!