Open tueboesen opened 4 years ago
You need a visual studio command prompt, for example for Visual Studio 2019, you would run (Windows-key and R )
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
or start typing 'x64 Native Tools Command Prompt for VS 2019' in the search bar.
You also need ninja binary in the path, download it from here: https://github.com/ninja-build/ninja/releases unzip and copy it in your path (type 'path' to find some directory)
Then run
set DISTUTILS_USE_SDK=1
python setup.py build
python setup.py install
In case of an error related to lltm.o not found, you can rename the lltm.obj to lltm.o, in my case in the build\temp.win-amd64-3.7\Release folder. Then, after the extension builds and installs fine, it will report an error, not finding the torch dlls, the error is like:
ImportError: DLL load failed: The specified module could not be found.
Just copy the dlls from Python37\Lib\site-packages\torch\lib or start python from that directory Then you can run python and import lltm_cpp and find the forward and backward extension:
C:\Python37\Lib\site-packages\torch\lib>python
Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import lltm_cpp
>>> print(dir(lltm_cpp))
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'backward', 'forward']
The developers of extension-cpp probably care mostly about Linux, not Windows.
For me, my solution is to buy a ubuntu PC and install NVIDIA packages. And I can run the code!
For those stumbling upon this thread, below works for me:
cl
to your PATH environment variable (see here). Steps:
cl
by executing where cl
in a Windows command line terminal.For those stumbling upon this thread, below works for me:
- Install Build Tools for Visual Studio
Make sure you add compiler
cl
to your PATH environment variable (see here). Steps:
- Go to your environment variables in Windows
- select the PATH environment variable
- Add the path to your MSVC compiler. Example for VS2019 Build Tools: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64
- Verify that Windows can find
cl
by executingwhere cl
in a Windows command line terminal.
I have the cl PATH on the User variables and the System variables but still where cl
returns INFO: Could not find files for the given patterns(s)
What else can I do?
Cupy has a mechanism to find cl.exe
automatically without one having to use manual steps to call vcvars64.ba
t or manually modify the PATH
variable (See here). It would be super convenient to has a similar mechanism added to pytorch.
I am trying to use the JIT cpp extension, and have a script from my friend, who is able to run it in linux, but whenever I run it on windows, it fails. The error is quite clear, it seems like it can’t find the cl.exe compiler.
The script fails on the load statement below:
With the following message:
I’m running python 3.8 and a pip list gives the following:
How can I fix this issue?