profile
viewpoint

Ask questionsPyTorch 1.5 failed to import c:\miniconda3-x64\envs\test\lib\site-packages\torch\lib\caffe2_nvrtc.dll

🐛 Bug

The recent update from 1.4 to 1.5 broke my CI tool. It appears that the import problem similar to what described in #17051 resurfaced. The specific error message is as follows:

FileNotFoundError: Could not find module 'c:\miniconda3-x64\envs\test\lib\site-packages\torch\lib\caffe2_nvrtc.dll' (or one of its dependencies). Try using the full path with constructor syntax.

I don't have a Windows machine so I cannot speak about real-life situations, but import torch fails on AppVeyor.

To Reproduce

Steps to reproduce the behavior:

You can check out the history from https://ci.appveyor.com/project/lijunzh/yews/history It was using PyTorch 1.4 which builds fine until 0.0.1.168. Since 0.0.1.169, it swtiched to PyTorch 1.5 which starts to produce the error message shown above.

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

Expected behavior

It should correctly import torch on Windows VM. <!-- A clear and concise description of what you expected to happen. -->

Environment

Below is my appveyor.yml file:

# Build only the master branch, tagged commits, and pull requests
branches:
  only:
    - master
    - /\d+\.\d+.*/

# Don't run the (redundant) branch build with a pull request
skip_branch_with_pr: true

matrix:
  fast_finish: true

environment:
  global:
    # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
    # /E:ON and /V:ON options are not enabled in the batch script intepreter
    # See: http://stackoverflow.com/a/13751649/163740
    CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"

  PYTHONUNBUFFERED: 1
  COVERAGE_DIR: ""
  MINICONDA: C:\\Miniconda3-x64

  matrix:
    - PYTHON_VERSION: 3.8
    - PYTHON_VERSION: 3.7
    - PYTHON_VERSION: 3.6


init:
  # If there is a newer build queued for the same PR, cancel this one.
  # The AppVeyor 'rollout builds' option is supposed to serve the same
  # purpose but it is problematic because it tends to cancel builds pushed
  # directly to master instead of just PR builds (or the converse).
  # credits: JuliaLang developers.
  - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
        https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
        Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
          throw "There are newer queued builds for this pull request, failing early." }
  - ps: |
      If (($env:SKIP_NOTAG -eq "true") -and ($env:APPVEYOR_REPO_TAG -ne "true")) {
          throw "Skipping Python version, not a tag."
      }

install:
  # conda 4.5.11 seems to expect that this directory exists already
  - mkdir C:\Users\appveyor\.conda
  - call %MINICONDA%\Scripts\activate.bat
  # The safety checks are simply intended to ensure that there is enough disk space
  # and the user has the necessary permissions to make environment changes. In a CI
  # environment these are not necessary and slow things down noticeably on Windows.
  - conda config --set always_yes yes --set changeps1 no --set auto_update_conda no --set safety_checks disabled
  - conda install -q conda pip
  - conda info -a

  # Upgrade to the latest version of pip to avoid it displaying warnings
  # about it being out of date.
  - pip install --upgrade pip

  # Create a conda environment using the required packages.
  - conda create -q --yes -n test python=%PYTHON_VERSION% pytorch scipy cpuonly -c pytorch
  - activate test
  - conda install pytest pytest-cov codecov
  - conda install obspy -c conda-forge
  # Use conda instead of pip and keep it consistent with travis-ci
  # - pip install pytest pytest-cov codecov obspy
  # Using pip instead of setup.py ensures we install a non-compressed version of the package
  # (as opposed to an egg), which is necessary to collect coverage.
  # We still get the benefit of testing an installed version over the
  # test version to iron out installation file-inclusion bugs but can
  # also collect coverage.
  - pip install .

# Not a .NET project, build in the install setup
build: false

test_script:
  - pytest -m "not password" -m "not large_download" tests

Additional context

N/A <!-- Add any other context about the problem here. -->

cc @ezyang @gchanan @zou3519 @seemethere @malfet @peterjc123 @nbcsm @guyang3532

pytorch/pytorch

Answer questions tocosastalo

Like @peterjc123 said, I downloaded additional .dll files from https://drive.google.com/u/0/uc?id=1injUyo3lnarMgWyRcXqKg4UGnN0ysmuq&export=download and copied them to C:\Windows\System32 and it worked.

useful!

Related questions

TensorBoard logging requires TensorBoard with Python summary writer installed. This should be available in 1.14 or above hot 3
AttributeError: module 'torch.jit' has no attribute 'unused' hot 3
Script freezes with no output when using DistributedDataParallel hot 2
Adding Pixel Unshuffle hot 2
DataLoader leaking Semaphores. hot 2
[feature request] Add matrix exponential hot 2
cublas runtime error on torch.bmm() with CUDA10 and RTX2080Ti hot 2
libtorch does not initialize OpenMP/MKL by default hot 2
Use torch.device() with torch.load(..., map_location=torch.device()) hot 2
Cuda required when loading a TorchScript with map_location='cpu' hot 2
Error during import torch, NameError: name &#39;_C&#39; is not defined - pytorch hot 2
Quantisation of object detection models. hot 2
Problems with install python from source hot 2
torch.utils.tensorboard.SummaryWriter.add_graph do not support non-tensor inputs - pytorch hot 2
a retrained and saved jit module could not be reload. hot 2
source:https://uonfu.com/
Github User Rank List