6

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

  • CUDA 10.0
  • Python 3.6
  • Chainer 5.4.0
  • CuPy 5.4.0

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?

talonmies
  • 70,661
  • 34
  • 192
  • 269
Amber Ji
  • 63
  • 1
  • 1
  • 3
  • 1
    did you do `pip install cupy` ? – Robert Crovella Jun 12 '19 at 14:00
  • I did. <!CUDA_PATH=/opt/nvidia/cuda pip3 install cupy>. and it shows "Successfully installed cupy-6.0.0" – Amber Ji Jun 12 '19 at 14:04
  • Maybe this is related. https://stackoverflow.com/questions/49135065/is-it-possible-to-install-cupy-on-google-colab – corochann Jun 12 '19 at 22:41
  • @corochann Thanks. I've already seen this post which basically says Colab has a built-in CuPy. I've tried the built-in Cupy, but it popped up the same error . I then installed CuPy manually via <!CUDA_PATH=/opt/nvidia/cuda pip3 install cupy>, but the same error occured. – Amber Ji Jun 12 '19 at 23:40
  • How about trying uninstall exsiting cupy `pip uninstall cupy` (please type this more than **2 times** to verify all installed cupy version existed in system are uninstalled). And install cupy with `pip install cupy --no-cache-dir`? --no-cache-dir option is important to re-build cupy from source. – corochann Jun 13 '19 at 05:31
  • @corochann If I uninstall some built-in package in Colab (such as CuPy 5.4.0) today, will Colab automatically restore it when I restart the kernel tomorrow? If not, I'm afraid that I could mess up with CuPy, especially when it comes to environment variables. – Amber Ji Jun 13 '19 at 11:48

2 Answers2

3

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

Ioannis Nasios
  • 8,292
  • 4
  • 33
  • 55
-1
import time 
import cupy as cp
import numpy as np
s = time.time()
A = np.random.randint(10, size=(1000,1000))
C = A.transpose()
e = time.time()
print("waktu CPU:",e - s, "detik")

s = time.time()
A = cp.random.radint (10,size=(1000,1000))
C = A. transpose()
cp.cuda.Stream.null.synchronize()`enter code here`
e = time.time()
print("waktu GPU:",e - s, "detik")
  • 1
    This does not address the question at all. Please read through [how to answer](https://stackoverflow.com/help/how-to-answer). – AlexK Apr 12 '23 at 20:05