Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

windows link error #18

Open
kfpandayang opened this issue Mar 12, 2018 · 6 comments
Open

windows link error #18

kfpandayang opened this issue Mar 12, 2018 · 6 comments

Comments

@kfpandayang
Copy link

I build this demo according to README, but ran into the following error:

c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\cuda_fp16.hpp(122): note: 参见“__half”的声明
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1/lib/x64" "/LIBPATH:C:\Program Files\NVIDIA Corporation\NvToolsExt/lib/x64" /LIBPATH:C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\ffi....\lib /LIBPATH:C:\ProgramData\Anaconda3\libs /LIBPATH:C:\ProgramData\Anaconda3\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x64" /EXPORT:PyInit__my_lib .\Release_my_lib.obj .\Release\opensource\pytorch_windows\extension-ffi\script\src\my_lib.obj .\Release\opensource\pytorch_windows\extension-ffi\script\src\my_lib_cuda.obj /OUT:._my_lib.pyd /IMPLIB:.\Release_my_lib.lib
正在创建库 .\Release_my_lib.lib 和对象 .\Release_my_lib.exp
my_lib.obj : error LNK2001: 无法解析的外部符号 __imp_THFloatTensor_fill
my_lib.obj : error LNK2001: 无法解析的外部符号 __imp_THFloatTensor_resizeAs
my_lib.obj : error LNK2001: 无法解析的外部符号 __imp_THFloatTensor_isSameSizeAs
my_lib.obj : error LNK2001: 无法解析的外部符号 __imp_THFloatTensor_cadd
my_lib_cuda.obj : error LNK2001: 无法解析的外部符号 __imp_THCudaTensor_fill
my_lib_cuda.obj : error LNK2001: 无法解析的外部符号 "struct THCState * state" (?state@@3PEAUTHCState@@ea)
my_lib_cuda.obj : error LNK2001: 无法解析的外部符号 __imp_THCudaTensor_isSameSizeAs
my_lib_cuda.obj : error LNK2001: 无法解析的外部符号 __imp_THCudaTensor_resizeAs
my_lib_cuda.obj : error LNK2001: 无法解析的外部符号 __imp_THCudaTensor_cadd
._my_lib.pyd : fatal error LNK1120: 9 个无法解析的外部命令
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\distutils_msvccompiler.py", line 519, in link
self.spawn([self.linker] + ld_args)
File "C:\ProgramData\Anaconda3\lib\distutils_msvccompiler.py", line 542, in spawn
return super().spawn(cmd)
File "C:\ProgramData\Anaconda3\lib\distutils\ccompiler.py", line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File "C:\ProgramData\Anaconda3\lib\distutils\spawn.py", line 38, in spawn
_spawn_nt(cmd, search_path, dry_run=dry_run)
File "C:\ProgramData\Anaconda3\lib\distutils\spawn.py", line 81, in _spawn_nt
"command %r failed with exit status %d" % (cmd, rc))
distutils.errors.DistutilsExecError: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\link.exe' failed with exit status 1120

@kfpandayang
Copy link
Author

kfpandayang commented Mar 12, 2018

I fixed the error with following step:

  1. change src according to #5520

  2. link against ATen.lib with the following modification to build.py:

sources = ['src/my_lib.cpp']
headers = ['src/my_lib.h']
defines = []
with_cuda = False

if torch.cuda.is_available():
print('Including CUDA code.')
sources += ['src/my_lib_cuda.cpp']
headers += ['src/my_lib_cuda.h']
defines += [('WITH_CUDA', None)]
with_cuda = True

ffi = create_extension(
'_ext.my_lib',
headers=headers,
sources=sources,
define_macros=defines,
relative_to=file,
with_cuda=with_cuda,
extra_compile_args=["-std=c99"],
libraries=["ATen"]
)

but python test.py crashed, i found it was caused by the cuda code my_lib.my_lib_add_forward_cuda(input1, input2, output) ,but how can I debug this, there is no information about the crash

@haha996
Copy link

haha996 commented Jun 13, 2018

hi, have you sort out this problem? i just got the same question as yours

@li91yang
Copy link

I got the same error. Is there anyone know how to fix it?

@li91yang
Copy link

When trying to compile C extension, I got error( VerificationError: CompileError: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2), and tried all the methods mentioned, but all can't fix it. Is there anyone know how to fix it?
OS: Windows 10
PyTorch version: 0.4.1
How you installed PyTorch (conda, pip, source): conda
Python version: Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:05:27) [MSC v.1900 64 bit (AMD64)] on win32
CUDA/cuDNN version: CUDA-9.0
GPU models and configuration: VS 2015

generating C:\Users\liyang\AppData\Local\Temp\tmp65k1yok8_my_lib.c
setting the current directory to 'C:\Users\liyang\AppData\Local\Temp\tmp65k1yok8'
running build_ext
building '_my_lib' extension
creating Release
creating Release\models
creating Release\models\ops
creating Release\models\ops\learn
creating Release\models\ops\learn\11
creating Release\models\ops\learn\11\src
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\torch\utils\ffi....\lib\include -IC:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\torch\utils\ffi....\lib\include\TH -IC:\Users\liyang\Anaconda3\pkgs\pytorch-cpu-0.4.1-py35_cpuhe774522_1\Lib\site-packages\torch\lib\include -IC:\Users\liyang\Anaconda3\envs\pytorch41\include -IC:\Users\liyang\Anaconda3\envs\pytorch41\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_my_lib.c /Fo.\Release_my_lib.obj -std=c99
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\torch\utils\ffi....\lib\include -IC:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\torch\utils\ffi....\lib\include\TH -IC:\Users\liyang\Anaconda3\pkgs\pytorch-cpu-0.4.1-py35_cpuhe774522_1\Lib\site-packages\torch\lib\include -IC:\Users\liyang\Anaconda3\envs\pytorch41\include -IC:\Users\liyang\Anaconda3\envs\pytorch41\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /EHsc /TpI:\D435\DepthCNN\models\ops\learn\11\src\my_lib.cpp /Fo.\Release\D435\DepthCNN\models\ops\learn\11\src\my_lib.obj -std=c99
Traceback (most recent call last):

File "C:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
execfile(filename, namespace)

File "C:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "I:/models/ops/learn/11/build.py", line 38, in
ffi.build()

File "C:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\torch\utils\ffi_init_.py", line 189, in build
_build_extension(ffi, cffi_wrapper_name, target_dir, verbose)

File "C:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\torch\utils\ffi_init_.py", line 111, in _build_extension
outfile = ffi.compile(tmpdir=tmpdir, verbose=verbose, target=libname)

File "C:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\cffi\api.py", line 697, in compile
compiler_verbose=verbose, debug=debug, **kwds)

File "C:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\cffi\recompiler.py", line 1520, in recompile
compiler_verbose, debug)

File "C:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\cffi\ffiplatform.py", line 22, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)

File "C:\Users\liyang\Anaconda3\envs\pytorch41\lib\site-packages\cffi\ffiplatform.py", line 58, in _build
raise VerificationError('%s: %s' % (e.class.name, e))

VerificationError: CompileError: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2

@ChongJiao
Copy link

I meet this error too. who knows how to fix it?

@GreenTeaHua
Copy link

I meet this error too.
pytorch 0.41

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants