few-shot icon indicating copy to clipboard operation
few-shot copied to clipboard

Fail to run the matching_nets.py

Open Dennis-Chu opened this issue 4 years ago • 6 comments

Hi, I am new to python. Can any one help to make this code sample work?

I want to try it out the "matching_nets.py" in my requirement. My notebook is lenovo Carbon X1 without GPU embedded. My environment using Anaconda Command Prompt.

I got following errors File "matching_nets.py", line 18, in assert torch.cuda.is_available() AssertionError

Following is the package list Package Version


atomicwrites 1.2.1 attrs 18.2.0 backcall 0.1.0 bleach 3.0.2 certifi 2020.4.5.1 cffi 1.14.0 cloudpickle 1.3.0 colorama 0.4.3 cycler 0.10.0 cytoolz 0.10.1 dask 2.14.0 decorator 4.4.2 defusedxml 0.5.0 entrypoints 0.2.3 graphviz 0.10.1 imageio 2.8.0 ipykernel 5.1.0 ipython 7.1.1 ipython-genutils 0.2.0 ipywidgets 7.4.2 jedi 0.13.1 Jinja2 2.10 jsonschema 2.6.0 jupyter 1.0.0 jupyter-client 5.2.3 jupyter-console 6.0.0 jupyter-core 4.4.0 kiwisolver 1.2.0 MarkupSafe 1.1.1 matplotlib 3.2.1 mistune 0.8.4 mkl-fft 1.1.0 mkl-service 2.3.0 more-itertools 4.3.0 nbconvert 5.4.0 nbformat 4.4.0 networkx 2.4 notebook 5.7.0 numpy 1.18.2 olefile 0.46 pandas 0.23.4 pandocfilters 1.4.2 parso 0.3.1 pexpect 4.6.0 pickleshare 0.7.5 Pillow 7.1.1 pip 20.0.2 pluggy 0.8.0 prometheus-client 0.4.2 prompt-toolkit 2.0.7 ptyprocess 0.6.0 py 1.7.0 pycparser 2.20 Pygments 2.2.0 pyparsing 2.4.6 pytest 3.9.3 python-dateutil 2.8.1 pytz 2018.7 PyWavelets 1.1.1 pywinpty 0.5.7 PyYAML 5.3.1 pyzmq 17.1.2 qtconsole 4.4.2 scikit-image 0.16.2 scipy 1.4.1 Send2Trash 1.5.0 setuptools 46.1.3.post20200325 six 1.14.0 terminado 0.8.1 testpath 0.4.2 toolz 0.10.0 torch 1.4.0 torch-nightly 1.2.0.dev20190723 torchvision 0.5.0 tornado 6.0.4 tqdm 4.28.1 traitlets 4.3.2 wcwidth 0.1.7 webencodings 0.5.1 wheel 0.34.2 widgetsnbextension 3.4.2 wincertstore 0.2

Dennis-Chu avatar Apr 06 '20 14:04 Dennis-Chu

You haven't installed cuda, i would recommend running on google colab till all the errors are solved Try this https://www.wikihow.com/Run-CUDA-C-or-C%2B%2B-on-Jupyter-(Google-Colab)

RajeshPandey057 avatar Apr 07 '20 03:04 RajeshPandey057

I tried. and get the following error after following the instruction.

          CUDA error copying to Host: no CUDA-capable device is detected
          result is 0

Is CUDA only work on GPU computer, My Lenovo notebook computer doesn't have GPU?

Any CPU based solution/library to make this source code work on my computer?

Dennis-Chu avatar Apr 07 '20 06:04 Dennis-Chu

In fact, I had tried to install

conda install -c anaconda cudatoolkit

it can successfully install the toolkit in " Anaconda Prompt", but it still not work finally.

Dennis-Chu avatar Apr 07 '20 06:04 Dennis-Chu

Yes actually, CUDA needs GPU. But you can go to the official PyTorch.org and follow the steps accordingly. enter image description here image

Select your preferences and you will see an appropriate command below on the page.

If you don't have GPU in the system, set CUDA as None

Example command:

conda install pytorch-cpu torchvision-cpu -c pytorch

RajeshPandey057 avatar Apr 13 '20 08:04 RajeshPandey057

These are the commands to install the pytorch version 1.0.0 and pyvision version 0.2.1 I am trying with cuda 10 You may try with cpu only

CUDA 10.0

conda install pytorch==1.0.0 torchvision==0.2.1 cuda100 -c pytorch

CUDA 9.0

conda install pytorch==1.0.0 torchvision==0.2.1 cuda90 -c pytorch

CUDA 8.0

conda install pytorch==1.0.0 torchvision==0.2.1 cuda80 -c pytorch

CPU Only

conda install pytorch-cpu==1.0.0 torchvision-cpu==0.2.1 cpuonly -c pytorch

RajeshPandey057 avatar Apr 13 '20 08:04 RajeshPandey057

Just try to install CPU only package and show the installation success. But still got the same error

Traceback (most recent call last): File "matching_nets.py", line 18, in assert torch.cuda.is_available() AssertionError

The package installation message.

(fewshot) C:\Windows\system32>conda install pytorch-cpu==1.0.0 torchvision-cpu==0.2.1 cpuonly -c pytorch Collecting package metadata (current_repodata.json): done Solving environment: done

Package Plan

environment location: C:\Users\denni\Anaconda3\envs\fewshot

added / updated specs: - cpuonly - pytorch-cpu==1.0.0 - torchvision-cpu==0.2.1

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
cpuonly-1.0                |                0           2 KB  pytorch
pytorch-cpu-1.0.0          |      py3.6_cpu_1        56.6 MB  pytorch
torchvision-cpu-0.2.1      |             py_2          37 KB  pytorch
------------------------------------------------------------
                                       Total:        56.7 MB

The following NEW packages will be INSTALLED:

cpuonly pytorch/noarch::cpuonly-1.0-0 pytorch-cpu pytorch/win-64::pytorch-cpu-1.0.0-py3.6_cpu_1 torchvision-cpu pytorch/noarch::torchvision-cpu-0.2.1-py_2

Proceed ([y]/n)? y

Downloading and Extracting Packages pytorch-cpu-1.0.0 | 56.6 MB | ############################################################################ | 100% torchvision-cpu-0.2. | 37 KB | ############################################################################ | 100% cpuonly-1.0 | 2 KB | ############################################################################ | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done

Dennis-Chu avatar Apr 14 '20 15:04 Dennis-Chu