python-3.xpytorchgoogle-colaboratorycupy

No module named 'cupy' on Google Colab


I'm working on the FastPhotoStyle project: https://github.com/NVIDIA/FastPhotoStyle

and I follow the steps of its tutorial: https://github.com/NVIDIA/FastPhotoStyle/blob/master/TUTORIAL.md

I'm running Example 1 on Google Colab where default environment is

This is how I tried on Colab Notebook:

https://colab.research.google.com/drive/1oBgdJgXCLlUQhpwPoG1Uom3OKTzHR4BF

After running

!python3 demo.py --output_image_path results/example1.png

Here's the error message I got:

Traceback (most recent call last): File "demo.py", line 9, in

import process_stylization

File "/content/drive/FastPhotoStyle/process_stylization.py", line 14, in

from smooth_filter import smooth_filter

File "/content/drive/FastPhotoStyle/smooth_filter.py", line 327, in

from cupy.cuda import function

ModuleNotFoundError: No module named 'cupy'

Could someone help me with it please?


Solution

  • have you tried running the demo with python full path?

    !/usr/local/lib/python3.6//bin/python3 demo.py --output_image_path 
    

    or running without anaconda installation by simple install all necessary libraries

    !pip install cupy
    

    or see installation instructions here