添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hi Jack, in this case almost surely the problem is due to different environments.
In the command line (where it works) run
where python
You should get the location of the binary for the environment. For example, in my case (I regrettably use the base env for everything) I get:
C:\Users\valer\anaconda3\python.exe
I don’t use Visual Studio Code but you should find your answer here:
Using Python Environments in Visual Studio Code . Your VScode interpreter should be the same as the one outputted by the command line.
Let me know if it works :slight_smile:

OK the issue has been resolved and I think the reason this all happened is because I have conda installed in different user’s directory. (This is due to the fact that my initial user name is in Non-English language so it was impossible to install conda so I created a dummy user to install conda)

So thank you ptrblack and Valerio_Biscione. I don’t think I would have solved issue anytime soon without your help!!

when I run “conda install torch”, I got this:
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  • torch
  • Current channels:

  • https://conda.anaconda.org/conda-forge/linux-64
  • https://conda.anaconda.org/conda-forge/noarch
  • https://conda.anaconda.org/r/linux-64
  • https://conda.anaconda.org/r/noarch
  • https://repo.anaconda.com/pkgs/main/linux-64
  • https://repo.anaconda.com/pkgs/main/noarch
  • https://repo.anaconda.com/pkgs/r/linux-64
  • https://repo.anaconda.com/pkgs/r/noarch
  • To search for alternate channels that may provide the conda package you’re
    looking for, navigate to

    https://anaconda.org
    

    and use the search bar at the top of the page.

    Thanks ptrblck.
    Actually, I have tried both already. I got this

    Collecting package metadata (repodata.json): done
    Solving environment: done

    Package Plan

    environment location: /home/sol/anaconda3/envs/concat1

    added / updated specs:
    - pytorch

    The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pytorch-0.4.0              |   py36hdf912b8_0       224.9 MB  defaults
    ------------------------------------------------------------
                                           Total:       224.9 MB
    

    The following NEW packages will be INSTALLED:

    intel-openmp pkgs/main/linux-64::intel-openmp-2021.2.0-h06a4308_610
    nccl pkgs/main/linux-64::nccl-1.3.5-cuda9.0_0
    pytorch pkgs/main/linux-64::pytorch-0.4.0-py36hdf912b8_0

    The following packages will be SUPERSEDED by a higher-priority channel:

    mkl conda-forge::mkl-2021.2.0-h726a3e6_389 → pkgs/main::mkl-2018.0.3-1

    Proceed ([y]/n)? y

    Downloading and Extracting Packages
    pytorch-0.4.0 | 224.9 MB | ##################################### | 100%
    Preparing transaction: done
    Verifying transaction: done
    Executing transaction: done

    But still can’t import torch. And got: Torch CUDA is not Available

    I observe the following problem:

    conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c nvidia
    pytorch                       1.8.1  py3.9_cuda11.1_cudnn8.0.5_0
    conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch -c nvidia
    pytorch                       1.8.1  py3.9_cpu_0
    

    can you help me figure out why the CPU only version is installed when using version 11.0 of the cudatoolkit?

    @ptrblck
    Hello ptrblck,

    Do we need to explicitly install cudnn after running following command?

    conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch-lts -c nvidia

    Thanks ans regards,
    sudhir

    No, cudnn8.0.5 will be installed using your posted command and you can check it via:

    torch.backends.cudnn.is_available()
    torch.backends.cudnn.version()
                  

    @ptrblck -

    I know this thread seems to have run on forever, and please forgive me for asking, but I’m seemingly having the same issue on my Ubuntu 18.04 machine. I have followed what instructions I can above, but I’m also getting a CUDA Available = False result. Below is the output of environment, can you please provide guidance? thanks

    (base) grbman@Zidane:~/GFPGAN$ nvidia-smi
    Thu Jan 6 15:33:35 2022
    ±----------------------------------------------------------------------------+
    | NVIDIA-SMI 418.226.00 Driver Version: 418.226.00 CUDA Version: 10.1 |
    |-------------------------------±---------------------±---------------------+
    | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
    | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
    |===============================+======================+======================|
    | 0 Quadro K1100M Off | 00000000:01:00.0 On | N/A |
    | N/A 45C P0 N/A / N/A | 410MiB / 1991MiB | 1% Default |
    ±------------------------------±---------------------±---------------------+

    ±----------------------------------------------------------------------------+
    | Processes: GPU Memory |
    | GPU PID Type Process name Usage |
    |=============================================================================|
    | 0 1117 G /usr/lib/xorg/Xorg 55MiB |
    | 0 1233 G /usr/bin/gnome-shell 53MiB |
    | 0 1533 G /usr/lib/xorg/Xorg 163MiB |
    | 0 1661 G /usr/bin/gnome-shell 100MiB |
    | 0 2713 G …AAgAAAAAAAAACAAAAAAAAAA= --shared-files 31MiB |
    ±----------------------------------------------------------------------------+

    (base) grbman@Zidane:~/GFPGAN$ nvcc -V
    nvcc: NVIDIA (R) Cuda compiler driver
    Built on Fri_Nov__3_21:07:56_CDT_2017
    Cuda compilation tools, release 9.1, V9.1.85

    (base) grbman@Zidane:~/GFPGAN$ gcc --version
    gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    (base) grbman@Zidane:~/Downloads$ python3 collect_env.py
    Collecting environment information…
    PyTorch version: 1.10.1
    Is debug build: False
    CUDA used to build PyTorch: Could not collect
    ROCM used to build PyTorch: N/A

    OS: Ubuntu 18.04.6 LTS (x86_64)
    GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
    Clang version: Could not collect
    CMake version: Could not collect
    Libc version: glibc-2.27

    Python version: 3.9.7 (default, Sep 16 2021, 13:09:58) [GCC 7.5.0] (64-bit runtime)
    Python platform: Linux-5.4.0-92-generic-x86_64-with-glibc2.27
    Is CUDA available: False
    CUDA runtime version: 9.1.85
    GPU models and configuration: GPU 0: Quadro K1100M
    Nvidia driver version: 418.226.00
    cuDNN version: Could not collect
    HIP runtime version: N/A
    MIOpen runtime version: N/A

    Versions of relevant libraries:
    [pip3] mypy-extensions==0.4.3
    [pip3] numpy==1.20.3
    [pip3] numpydoc==1.1.0
    [pip3] torch==1.10.1
    [pip3] torchaudio==0.10.1
    [pip3] torchvision==0.11.2
    [conda] blas 1.0 mkl
    [conda] cpuonly 2.0 0 pytorch
    [conda] cudatoolkit 10.2.89 hfd86e86_1
    [conda] mkl 2021.4.0 h06a4308_640
    [conda] mkl-service 2.4.0 py39h7f8727e_0
    [conda] mkl_fft 1.3.1 py39hd3c417c_0
    [conda] mkl_random 1.2.2 py39h51133e4_0
    [conda] mypy_extensions 0.4.3 py39h06a4308_0
    [conda] numpy 1.20.3 py39hf144106_0
    [conda] numpy-base 1.20.3 py39h74d4b33_0
    [conda] numpydoc 1.1.0 pyhd3eb1b0_1
    [conda] pytorch 1.10.1 py3.9_cpu_0 pytorch
    [conda] pytorch-mutex 1.0 cpu pytorch
    [conda] torchaudio 0.10.1 py39_cpu [cpuonly] pytorch
    [conda] torchvision 0.11.2 py39_cpu [cpuonly] pytorch

    Yeah, so it looks like now I have a mis-match between what is available in the driver for my K1100M (Cuda 10.1) and the PyTorch build which is Cuda 10.2.

    …guess we’re gonna have to upgrade a video card. Thanks for all the help…I do appreciate the effort

    Pardon me guys, may I ask what’s the command that allows me to download PyTorch with GPU connectivity. I’ve used the suggested ones from the here but it still provides me packages with cpuonly version.

    conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
    
    The following packages will be downloaded:
        package                    |            build
        ---------------------------|-----------------
        pytorch-1.10.1             |      py3.9_cpu_0        86.2 MB  pytorch
        torchaudio-0.10.1          |         py39_cpu         4.3 MB  pytorch
        torchvision-0.11.2         |         py39_cpu         7.1 MB  pytorch
        ------------------------------------------------------------
                                               Total:        97.6 MB
    The following NEW packages will be INSTALLED:
      pytorch            pytorch/linux-64::pytorch-1.10.1-py3.9_cpu_0
      torchaudio         pytorch/linux-64::torchaudio-0.10.1-py39_cpu
      torchvision        pytorch/linux-64::torchvision-0.11.2-py39_cpu
    

    PS: I’m using RTX 3080 and requires sm_86 CUDA capability.