Skip to content
ProGamerGov edited this page Nov 16, 2019 · 28 revisions

Error Messages


Remember to try updating to the latest version of neural-style-pt, if you have not done so already, to see if that resolves your issue.


Windows:

C:\WINDOWS\system32>pip3 install neural-style
Collecting neural-style
  Using cached https://files.pythonhosted.org/packages/81/6c/64001244d8574dbf425049812461c6ccd475b564a549a232a2489ed82d31/neural_style-0.4.9-py2.py3-none-any.whl
Collecting torchvision (from neural-style)
  Using cached https://files.pythonhosted.org/packages/b7/ff/091b4503d5f228bd1120db784e2c071617211b965a8a78018e75750c7199/torchvision-0.3.0-cp37-cp37m-win_amd64.whl
Requirement already satisfied: pillow in c:\users\user\appdata\local\programs\python\python37\lib\site-packages (from neural-style) (6.2.0)
Collecting torch (from neural-style)
  Using cached https://files.pythonhosted.org/packages/f8/02/880b468bd382dc79896eaecbeb8ce95e9c4b99a24902874a2cef0b562cea/torch-0.1.2.post2.tar.gz
Requirement already satisfied: numpy in c:\users\user\appdata\local\programs\python\python37\lib\site-packages (from torchvision->neural-style) (1.17.2)
Requirement already satisfied: six in c:\users\user\appdata\local\programs\python\python37\lib\site-packages (from torchvision->neural-style) (1.12.0)
Requirement already satisfied: pyyaml in c:\users\user\appdata\local\programs\python\python37\lib\site-packages (from torch->neural-style) (5.1.2)
ERROR: torchvision 0.3.0 has requirement torch>=1.1.0, but you'll have torch 0.1.2.post2 which is incompatible.
Installing collected packages: torch, torchvision, neural-style
  Running setup.py install for torch ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\user\appdata\local\programs\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-7lcu44qh\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-7lcu44qh\\torch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\user\AppData\Local\Temp\pip-record-1zqghozb\install-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\user\AppData\Local\Temp\pip-install-7lcu44qh\torch\
    Complete output (23 lines):
    running install
    running build_deps
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\user\AppData\Local\Temp\pip-install-7lcu44qh\torch\setup.py", line 265, in <module>
        description="Tensors and Dynamic neural networks in Python with strong GPU acceleration",
      File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\setuptools\__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "c:\users\user\appdata\local\programs\python\python37\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\users\user\appdata\local\programs\python\python37\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "c:\users\user\appdata\local\programs\python\python37\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\user\AppData\Local\Temp\pip-install-7lcu44qh\torch\setup.py", line 99, in run
        self.run_command('build_deps')
      File "c:\users\user\appdata\local\programs\python\python37\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\user\appdata\local\programs\python\python37\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\user\AppData\Local\Temp\pip-install-7lcu44qh\torch\setup.py", line 51, in run
        from tools.nnwrap import generate_wrappers as generate_nn_wrappers
    ModuleNotFoundError: No module named 'tools.nnwrap'
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\user\appdata\local\programs\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-7lcu44qh\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-7lcu44qh\\torch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\user\AppData\Local\Temp\pip-record-1zqghozb\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

C:\WINDOWS\system32>

Solution: Due to an issue with the PyTorch package, you'll have to first visit https://pytorch.org/ to get the correct pip3 command to install Torch on Windows. Ex: pip3 install torch===1.3.1 torchvision===0.4.2 -f https://download.pytorch.org/whl/torch_stable.html

Once PyTorch has been installed, you can install neural-style-pt via pip like normal.

See the neural-style-pt Windows Installation Guide for more details.


C:\WINDOWS\system32>neural-style
'neural-style' is not recognized as an internal or external command,
operable program or batch file.

Solution: Update to the latest version of the neural-style-pt pip package.


Permission Issues:

 -bash: ./starry_stanford.sh: Permission denied

Solution: Run chmod u+x ./starry_stanford.sh.

 -bash: ./starry_stanford_bigger.sh: Permission denied

Solution: Run chmod u+x ./starry_stanford_bigger.sh.


-gpu Issues:

Traceback (most recent call last):
  File "/usr/local/bin/neural-style", line 485, in <module>
    main()
  File "/usr/local/bin/neural-style", line 268, in main
    optimizer.step(feval)
  File "/usr/local/lib/python3.5/dist-packages/torch/optim/lbfgs.py", line 307, in step
    orig_loss = closure()
  File "/usr/local/bin/neural-style", line 257, in feval
    loss += mod.loss.to(backward_device)
RuntimeError: CUDA error: invalid device ordinal
Traceback (most recent call last):
  File "neural_style.py", line 474, in <module>
    main()
  File "neural_style.py", line 257, in main
    optimizer.step(feval)
  File "/usr/local/lib/python3.5/dist-packages/torch/optim/lbfgs.py", line 307, in step
    orig_loss = closure()
  File "neural_style.py", line 241, in feval
    loss += mod.loss.to(backward_device)
RuntimeError: CUDA error: invalid device ordinal

Cause: You listed/gave a device number to -gpu that doesn't exist.


Image size issues

Traceback (most recent call last):
  File "neural_style.py", line 474, in <module>
    main()
  File "neural_style.py", line 163, in main
    net(content_image)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/container.py", line 91, in forward
    input = module(input)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/pooling.py", line 547, in forward
    self.padding, self.ceil_mode, self.count_include_pad)
RuntimeError: Given input size: (1000x5x10). Calculated output size: (1000x0x5). Output size is too small at /home/ubuntu/pytorch/aten/src/THCUNN/generic/SpatialAveragePooling.cu:63
Traceback (most recent call last):
  File "neural_style.py", line 474, in <module>
    main()
  File "neural_style.py", line 163, in main
    net(content_image)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/container.py", line 92, in forward
    input = module(input)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/pooling.py", line 141, in forward
    self.return_indices)
  File "/usr/local/lib/python3.5/dist-packages/torch/_jit_internal.py", line 134, in fn
    return if_false(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/functional.py", line 487, in _max_pool2d
    input, kernel_size, stride, padding, dilation, ceil_mode)
RuntimeError: Given input size: (512x1x1). Calculated output size: (512x0x0). Output size is too small

Cause: The value used for -image_size is too small.


Incorrect Layer Names

Traceback (most recent call last):
  File "neural_style.py", line 474, in <module>
    main()
  File "neural_style.py", line 257, in main
    optimizer.step(feval)
  File "/usr/local/lib/python2.7/dist-packages/torch/optim/lbfgs.py", line 103, in step
    orig_loss = closure()
  File "neural_style.py", line 248, in feval
    loss.backward()
AttributeError: 'int' object has no attribute 'backward'
Traceback (most recent call last):
  File "neural_style.py", line 474, in <module>
    main()
  File "neural_style.py", line 257, in main
    optimizer.step(feval)
  File "/usr/local/lib/python2.7/dist-packages/torch/optim/adam.py", line 57, in step
    loss = closure()
  File "neural_style.py", line 248, in feval
    loss.backward()
AttributeError: 'int' object has no attribute 'backward'

Solution: If you were using the nin_imagenet.pth (NIN) model, you either forgot to specify the layers to use with -content_layers -style_layers, or you used invalid layers. NIN has different layer names than the VGG models.

Acceptable NIN layers are: relu0, relu1, relu2, relu3, relu5, relu6, relu7, relu8, relu9, relu10, relu11, relu12


Driver Errors:

Traceback (most recent call last):
  File "/usr/local/bin/neural-style", line 428, in <module>
    main()
  File "/usr/local/bin/neural-style", line 65, in main
    dtype = setup_gpu()
  File "/usr/local/bin/neural-style", line 293, in setup_gpu
    torch.cuda.set_device(params.gpu)
  File "/usr/local/lib/python3.5/dist-packages/torch/cuda/__init__.py", line 281, in set_device
    torch._C._cuda_setDevice(device)
  File "/usr/local/lib/python3.5/dist-packages/torch/cuda/__init__.py", line 178, in _lazy_init
    _check_driver()
  File "/usr/local/lib/python3.5/dist-packages/torch/cuda/__init__.py", line 108, in _check_driver
    of the CUDA driver.""".format(str(torch._C._cuda_getDriverVersion())))
AssertionError:
The NVIDIA driver on your system is too old (found version 9000).
Please update your GPU driver by downloading and installing a new
version from the URL: http://www.nvidia.com/Download/index.aspx
Alternatively, go to: https://pytorch.org to install
a PyTorch version that has been compiled with your version
of the CUDA driver.
Traceback (most recent call last):
  File "/usr/local/bin/neural-style", line 428, in <module>
    main()
  File "/usr/local/bin/neural-style", line 65, in main
    dtype = setup_gpu()
  File "/usr/local/bin/neural-style", line 293, in setup_gpu
    torch.cuda.set_device(params.gpu)
  File "/usr/local/lib/python3.5/dist-packages/torch/cuda/__init__.py", line 281, in set_device
    torch._C._cuda_setDevice(device)
  File "/usr/local/lib/python3.5/dist-packages/torch/cuda/__init__.py", line 178, in _lazy_init
    _check_driver()
  File "/usr/local/lib/python3.5/dist-packages/torch/cuda/__init__.py", line 108, in _check_driver
    of the CUDA driver.""".format(str(torch._C._cuda_getDriverVersion())))
AssertionError:
The NVIDIA driver on your system is too old (found version 9010).
Please update your GPU driver by downloading and installing a new
version from the URL: http://www.nvidia.com/Download/index.aspx
Alternatively, go to: https://pytorch.org to install
a PyTorch version that has been compiled with your version
of the CUDA driver.

Solution: You will need to update your drivers if you wish to use the downloaded version of PyTorch. This guide may be helpful for resolving the issue: https://askubuntu.com/questions/1077061/how-do-i-install-nvidia-and-cuda-drivers-into-ubuntu/1077063#1077063


  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 426, in to
    return self._apply(convert)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 202, in _apply
    module._apply(fn)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 224, in _apply
    param_applied = fn(param)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 424, in convert
    return t.to(device, dtype if t.is_floating_point() else None, non_blocking)
  File "/usr/local/lib/python3.5/dist-packages/torch/cuda/__init__.py", line 192, in _lazy_init
    _check_driver()
  File "/usr/local/lib/python3.5/dist-packages/torch/cuda/__init__.py", line 102, in _check_driver
    http://www.nvidia.com/Download/index.aspx""")
AssertionError:
Found no NVIDIA driver on your system. Please check that you
have an NVIDIA GPU and installed a driver from
http://www.nvidia.com/Download/index.aspx
VGG-19 Architecture Detected
Successfully loaded models/vgg19-d01eb7cb.pth
Traceback (most recent call last):
  File "neural_style.py", line 455, in <module>
    main()
  File "neural_style.py", line 59, in main
    cnn, layerList = loadCaffemodel(params.model_file, params.pooling, params.gpu, params.disable_check)
  File "/home/ubuntu/neural-style-pt/CaffeLoader.py", line 249, in loadCaffemodel
    cnn = cnn.cuda()
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 305, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 202, in _apply
    module._apply(fn)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 202, in _apply
    module._apply(fn)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 224, in _apply
    param_applied = fn(param)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 305, in <lambda>
    return self._apply(lambda t: t.cuda(device))
  File "/usr/local/lib/python3.5/dist-packages/torch/cuda/__init__.py", line 192, in _lazy_init
    _check_driver()
  File "/usr/local/lib/python3.5/dist-packages/torch/cuda/__init__.py", line 102, in _check_driver
    http://www.nvidia.com/Download/index.aspx""")
AssertionError:
Found no NVIDIA driver on your system. Please check that you
have an NVIDIA GPU and installed a driver from
http://www.nvidia.com/Download/index.aspx

Solution: Install the latest NVIDIA drivers.


Parameter Mistakes:

usage: neural-style [-h] [-style_image STYLE_IMAGE]
                    [-style_blend_weights STYLE_BLEND_WEIGHTS]
                    [-content_image CONTENT_IMAGE] [-image_size IMAGE_SIZE]
                    [-gpu GPU] [-content_weight CONTENT_WEIGHT]
                    [-style_weight STYLE_WEIGHT] [-normalize_weights]
                    [-tv_weight TV_WEIGHT] [-num_iterations NUM_ITERATIONS]
                    [-init {random,image}] [-init_image INIT_IMAGE]
                    [-optimizer {lbfgs,adam}] [-learning_rate LEARNING_RATE]
                    [-lbfgs_num_correction LBFGS_NUM_CORRECTION]
                    [-print_iter PRINT_ITER] [-save_iter SAVE_ITER]
                    [-output_image OUTPUT_IMAGE] [-style_scale STYLE_SCALE]
                    [-original_colors {0,1}] [-pooling {avg,max}]
                    [-model_file MODEL_FILE] [-disable_check]
                    [-backend {nn,cudnn,mkl,openmp,mkldnn,mkl,cudnn,cudnn,mkl}]
                    [-cudnn_autotune] [-seed SEED]
                    [-content_layers CONTENT_LAYERS]
                    [-style_layers STYLE_LAYERS]
                    [-multidevice_strategy MULTIDEVICE_STRATEGY]
                    [-download_models [DOWNLOAD_MODELS]]
neural-style: error: unrecognized arguments:
usage: neural_style.py [-h] [-style_image STYLE_IMAGE]
                       [-style_blend_weights STYLE_BLEND_WEIGHTS]
                       [-content_image CONTENT_IMAGE] [-image_size IMAGE_SIZE]
                       [-gpu GPU] [-content_weight CONTENT_WEIGHT]
                       [-style_weight STYLE_WEIGHT] [-normalize_weights]
                       [-tv_weight TV_WEIGHT] [-num_iterations NUM_ITERATIONS]
                       [-init {random,image}] [-init_image INIT_IMAGE]
                       [-optimizer {lbfgs,adam}]
                       [-learning_rate LEARNING_RATE]
                       [-lbfgs_num_correction LBFGS_NUM_CORRECTION]
                       [-print_iter PRINT_ITER] [-save_iter SAVE_ITER]
                       [-output_image OUTPUT_IMAGE] [-style_scale STYLE_SCALE]
                       [-original_colors {0,1}] [-pooling {avg,max}]
                       [-model_file MODEL_FILE] [-disable_check]
                       [-backend {nn,cudnn,mkl,mkldnn,openmp,mkl,cudnn,cudnn,mkl}]
                       [-cudnn_autotune] [-seed SEED]
                       [-content_layers CONTENT_LAYERS]
                       [-style_layers STYLE_LAYERS]
                       [-multidevice_strategy MULTIDEVICE_STRATEGY]
neural_style.py: error: unrecognized arguments:

Cause: You likely misspelled a parameter name.

Solution: Double check the spelling of each parameter in your set of commands, and make sure everything is spelt correctly.

Cause: You gave inputs to a parameter that doesn't take any inputs (like -cudnn_autotune, -normalize_weights, and -disable_check).

Solution: Remove any inputs that you put after the parameter in your list of commands.


GPU Device IDs Don't Match With nvidia-smi:

More information about how CUDA picks GPU IDs: https://stackoverflow.com/questions/13781738/how-does-cuda-assign-device-ids-to-gpus

You can use CUDA_DEVICE_ORDER=PCI_BUS_ID to fix the GPU order, if it's a problem.

Example:

CUDA_DEVICE_ORDER=PCI_BUS_ID python3 neural_style.py

You can control what GPUs are visible to PyTorch with CUDA_VISIBLE_DEVICES:

CUDA_VISIBLE_DEVICES=3 python3 neural_style.py

And both can be used simultaneously if you wish:

CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES=3 python3 neural_style.py

Model Download Script Doesn't Exist:

python: can't open file 'models/download_models.py': [Errno 2] No such file or directory

Cause: You aren't in the neural-style-pt directory.

Solution: Use the cd command to navigate to your neural-style-pt directory.