Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for compilation on Windows using mingw32 #287

Merged
merged 1 commit into from
Jul 10, 2015

Conversation

pkulchenko
Copy link
Contributor

This patch enables Torch7 compilation on Windows using mingw32 (or tdm-gcc with msys/msys2).

The steps needed:

  1. Install torch/cwrap and torch/paths
  2. Run the following commands:
cmake -E make_directory build
cd build
cmake .. -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DLUALIB=lua51.dll -DLUA_INCDIR="%LUA_INCDIR%" -DLUA_LIBDIR="%LUA_LIBDIR%" -DLUA="%LUA%"
make

Related ticket: #150. I've tested this under Windows 8.1 using msys2 and tdm-gcc-4.8, but it should work with other versions and configurations of mingw.

@soumith
Copy link
Member

soumith commented Jul 10, 2015

thanks Paul. A quick rebase? There seem to be merge conflicts.

@hughperkins
Copy link
Contributor

Cool :-)

@pkulchenko
Copy link
Contributor Author

@soumith, yes, I saw the conflict, but wasn't sure what to do about it as it's caused by another merge you just did:

<<<<<<< HEAD
IF (NOT MSVC)
    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration -Werror=format")
ENDIF(NOT MSVC)

=======
IF(MINGW)
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format")
ELSE()
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration -Werror=format")
ENDIF()
>>>>>>> Add support for compilation on Windows using mingw32.

I can probably turn it into this without much harm:

IF (NOT MSVC)
  IF (MINGW)
    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format")
  ELSE()
    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration -Werror=format")
  ENDIF(MINGW)
ENDIF(NOT MSVC)

@pkulchenko
Copy link
Contributor Author

@soumith, resolved, force-pushed.

soumith added a commit that referenced this pull request Jul 10, 2015
Add support for compilation on Windows using mingw32
@soumith soumith merged commit c669219 into torch:master Jul 10, 2015
@soumith
Copy link
Member

soumith commented Jul 10, 2015

Thanks paul :)

@pkulchenko pkulchenko deleted the torch-compile-mingw32 branch July 10, 2015 04:32
@pkulchenko
Copy link
Contributor Author

I haven't seen any problems yet, but will let you know if anything comes up ;).

@pkulchenko pkulchenko mentioned this pull request Jul 10, 2015
@hohoCode
Copy link

Hi @pkulchenko thanks for your work! Just wondering how about the installation of other torch packages? such as the nngraph, nn, optim etc packages using mingw for installation on Windows 8?

@pkulchenko
Copy link
Contributor Author

I guess I'll need to do the same for those packages as well. I'll take a look in few days and will link to this ticket to track the progress...

I'll probably start with nn as it's by far the most popular of the packages; @soumith, anything else you may suggest related to this?

@soumith
Copy link
Member

soumith commented Jul 13, 2015

I think this effort can largely base itself on the work of @diz-vara 's efforts. He already patched most of the core packages for Windows support using VC++. We will actively not block this, but we dont have the resources (or motivation) to actively support Windows either.

@hohoCode
Copy link

@diz-vara indeed did really great work for torch7 installation on Windows!

@diz-vara
Copy link
Contributor

Main packages (torch, nn, nnx, optim, luafilsystem, graph, nngraph, paths, xlua) just work in my VS2013 (x64) configuration from official repository.
Changes to the image (identical to the @wishstudio commit https://github.com/torch/image/pulls/wishstudio @wishstudio) are not approved, and changes to qtlua should be reviewed yet (but they do work).
I also wish to try @pkulchenko ZeroBrane Studio - in x64 configuration - but it requires a certain amount of work...

@pkulchenko
Copy link
Contributor Author

@soumith, it's a reasonable position, but I think it's a short step to add mingw support as well (since VC++ is already supported).

I also wish to try @pkulchenko ZeroBrane Studio - in x64 configuration - but it requires a certain amount of work...

@diz-vara, it should mostly work out of the box with a bit of configuration as it requires 64bit luasocket. I recently compiled it for the case like this and it's available here. ZeroBrane Studio allows you to debug 64bit apps even though it's running as 32bit app itself. You can ping me in IRC or over email if you run into any issues.

@pkulchenko
Copy link
Contributor Author

@hohoCode, I successfully compiled nn module, but there was one linking issue that I fixed with a change shown below.

@soumith, @diz-vara, any idea why I got a linker error on missing Lua symbols? I fixed it by adding lua51.dll to the list of the libraries, but I'm wondering how it works with VC++. The following patch fixes it for me:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1bc2bad..3ffd2a1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,5 +49,9 @@ ADD_TORCH_PACKAGE(nn "${src}" "${luasrc}")

 TARGET_LINK_LIBRARIES(nn luaT TH)

+IF(LUALIB)
+  TARGET_LINK_LIBRARIES(nn ${LUALIB})
+ENDIF()
+
 INSTALL(DIRECTORY "doc" DESTINATION "${Torch_INSTALL_LUA_PATH_SUBDIR}/nn")
 INSTALL(FILES "README.md" DESTINATION "${Torch_INSTALL_LUA_PATH_SUBDIR}/nn")

I then add -DLUALIB=lua51.dll to the cmake command. Any idea why it's missing?

@diz-vara
Copy link
Contributor

Paul @pkulchenko, I don't think we may bother @soumith (and other Torch/FAIR people) with Windows questions. There may be a lot of problems concerning libraries, build process, CMake and nmake behavior etc - and those are not Torch problems.
In my version of luajit-rocks I chose the explicit library linkage via #pragma directive in lua.h files:

#if !defined LUA_LIB & !defined LUA_CORE & !defined luajit_c & !defined _LJ_ARCH_H & !defined _LJ_DEF_H & !defined _LJ_OBJ_H

pragma comment( lib, "libluajit.lib")

endif

@pkulchenko
Copy link
Contributor Author

@diz-vara, it's an option, but I prefer not to modify the source files unless absolutely necessary. At least this explains how it works for you without that library being directly referenced.

I'll submit a pull request after I finish my tests as it seems to be working fine otherwise.

@hughperkins
Copy link
Contributor

There's a question on reddit about running torch on windows. Is there any working way of running torch on windows currently that we can point him to? https://www.reddit.com/r/MachineLearning/comments/3dgvvu/how_to_make_rnn_learning_faster/ He wants to run RNNs.

@soumith
Copy link
Member

soumith commented Jul 16, 2015

See the last answer on this thread: https://groups.google.com/forum/#!searchin/torch7/windows/torch7/A5XUU4u9Tjw/yvSJCBuLj4oJ

That is the most complete one as far as I know. But that instructions are based on an older fork of torch that was frozen.

@diz-vara
Copy link
Contributor

I've build cutorch on Windows (using my version of luajit-rocks - https://github.com/diz-vara/luajit-rocks), and it works. But it was done manually (with CMake-GUI and VS2013). I'll try to automate it - and pull the updates.

@hughperkins
Copy link
Contributor

I'll try to automate it - and pull the updates.

Cool. Sounds good. I'm currently partial to Paul Graham's idea that it's better to have a couple of people who really really want to use your project, than a zillion who kind of might do maybe

@PAK90
Copy link

PAK90 commented Jul 17, 2015

That was my question on reddit; I followed the link to the installer and thought it was exactly what I needed. Unfortunately it's missing the lfs and nngraph packages that the RNN script I'm using uses, and I can't get them to install using the torch-rocks.exe included in the installer... something about not finding the manifest, even when I point it at https://github.com/torch/rocks using --source. I had a luafilesystem.rockspec file that I tried running make on (again with torch-rocks.exe) but it complains about chmod not being a command and not being able to open source file lfs.c.

@diz-vara
Copy link
Contributor

@PAK90
I've updated instructions for my (Windows) version of luajit-rocks at
https://github.com/diz-vara/luajit-rocks
It works with cwrap, dok, ffmpeg, gnuplot, graph, image, luafilesystem, lub, matio, net-toolkit, nn, nngraph, nnx, optim, paths, sundown, sys, torch, torchffi, xlua, xml.

NB! lfs rock is called 'luafilesystem' - so you need to 'luarocks install luafilesystem'

It works also with qtlua, image, cutroch and cunn - but it requires some (a lot of) 'manual' work'

@PAK90
Copy link

PAK90 commented Jul 19, 2015

@soumith I downloaded and installed that Wintorch file. I've almost got it running with my RNN script, but it's missing some luarocks packages. I try to use torch-rocks.exe to install the packages but it always comes back with error messages regarding loading the manifest:

Warning: Failed searching manifest: Failed loading manifest: Failed fetching manifest for http://www.luarocks.org/repositories/rocks - Error fetching file: Failed downloading   http://www.luarocks.org/repositories/rocks/manifest

I know that the manifest file works fine, and I know the package I need is there. Below that error message, I also get:

'chmod' is not recognized as an internal or external command, operable program or batch file.

Not sure if they're related. The second one is daft as well; I have the MinGW path in my PATH variable, and I copied the chmod.exe file into the Torch7/bin folder itself (same one as where torch-rocks.exe is), yet it still complains.

Failing that, is there a way to point WinTorch at my luarocks install folder? I can easily use that luarocks install to download the rocks packages I need, but I can't copy them across to the Torch7 folder since all they are is a .rockspec file.

@diz-vara
Copy link
Contributor

@PAK90 : you can try to add directory with 'chmod' (and other unix-like staff) to your path.

@hughperkins
Copy link
Contributor

in python scripts, I notice sometimes that I have to give the Windows path, rather than the mingw path, when I execute external commands, so could be worth trying eg both c:\\torch\\install\\bin\\chmod.exe and /c/torch/install/bin/chmod.exe

@BTNC
Copy link
Contributor

BTNC commented Nov 3, 2016

Hi @vladimirdlc , it requires trivial change in torch to get the whole torch stack compiled for x86. I have built x86 torch locally, and have updated distro-win to support x86. Please pull latest changes and retry.
Note, x86 torch does not contain cuda packages and has 2g memory limitation.

According to your log, are you using x64 conda? x86 conda for x86 torch, x64 conda for x64 torch.

In case the build is messed up between x86 and x64, try uninstall torch before a fresh new build of torch.

install\torch-activate.cmd
uninstall.bat
install.bat

@vladimirdlc
Copy link

Hi @BTNC, it's working! :D
Have to try it in my other windows 7 setup, but here works all right.
image
I did had some trouble to install dpnn, any idea what may be the issue?

@BTNC
Copy link
Contributor

BTNC commented Nov 4, 2016

Hi @vladimirdlc , the readme contains instructions on how to install dpnn as a example of luarocks install not working for some torch packages. Actually it will work when dpnn's rockspec in torch rock server is up-to-date. Some torch packages can not be simply luarocks installed on windows.

@vladimirdlc
Copy link

That explains it, thanks again.

@BTNC
Copy link
Contributor

BTNC commented Nov 4, 2016

By the way, I see you are using x64 arm command prompt, are you trying to cross compile arm torch from x64 toolchain? I did not test cross compile torch with msvc.

@vladimirdlc
Copy link

I should have ran the wrong prompt.
But I tried yes, it seems to work the same.

@TyrionLanister
Copy link

TyrionLanister commented Nov 5, 2016

@BTNC
I'm getting linking error in platform X-64 for readline.dll from win-files\3rd\wineditline-2.101.
But libtorch.dll was linked successfully before it.
Here

[ 88%] Building C object CMakeFiles/torch.dir/random.c.obj
random.c
[ 91%] Building C object CMakeFiles/torch.dir/Generator.c.obj
Generator.c
[ 94%] Linking C shared module libtorch.dll

Creating library libtorch.lib and object libtorch.exp

[100%] Built target torch
cd build && nmake install
[ 48%] Built target TH
[ 54%] Built target luaT
[100%] Built target torch
Install the project...
-- Install configuration: "Release"

Then:
Build error: Failed compiling module readline.dll

# Creating library readline.lib and object readline.exp
readline.obj : error LNK2019: unresolved external symbol readline referenced in function f_readline
readline.obj : error LNK2019: unresolved external symbol add_history referenced in function f_add_history
readline.obj : error LNK2019: unresolved external symbol read_history referenced in function f_read_history
readline.obj : error LNK2019: unresolved external symbol write_history referenced in function f_write_history
readline.obj : error LNK2019: unresolved external symbol rl_completion_append_character referenced in function f_setup
readline.obj : error LNK2019: unresolved external symbol rl_completer_word_break_characters referenced in function f_setup
readline.obj : error LNK2019: unresolved external symbol rl_readline_name referenced in function f_setup
readline.obj : error LNK2019: unresolved external symbol rl_attempted_completion_function referenced in function f_setup
....\win-files\3rd\wineditline-2.101\lib64\edit_static.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64'
readline.dll : fatal error LNK1120: 8 unresolved externals
+++++++ Installation error!

errorx64

@BTNC
Copy link
Contributor

BTNC commented Nov 6, 2016

@TyrionLanister ,according to the following log:

warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64'

It looks like x64 trepl is trying to link with x86 editline static library which will not work. The reason I could guess is either trepl is using the downloaded prebuild wineditline static library which machine type is x86 (this is hardly possible if install.bat is called from a fresh command prompt and wineditline is rebuilt locally), or a x86 installation was run before this x64 installation. The x64 run will not call install-deps.bat again if last x86 run of install-deps.bat succeeded which leaves wineditline compiled for x86.

In this case I suggest you to uninstall it and reinstall from a clean state:
install\torch-activate
uninstall.bat
install.bat

If my guess is not your case, please detail your environment and procedure.

@TyrionLanister
Copy link

TyrionLanister commented Nov 6, 2016

@BTNC

Thanks it worked once I used "VS2015x64 native tools command prompt" .
Earlier I was working with cmd /k "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
which may be the reason(Look at the previous post screenshot)
!

@TyrionLanister
Copy link

TyrionLanister commented Nov 26, 2016

@BTNC
Hej

I have been able to install CUDA 8.0 in my windows 10 with NVIDIA GT740 M but I get this error *Unknown CUDA Architecture Name " nvcc " in CUDA_SELECT_NVCC_ARCH_FLAGS once installing cutorch.
The ${arch_name} is being printed as "nvcc" while it should be Kepler.
Screenshot: http://imgur.com/9BBCie1

-- got cuda version 8.0
-- Found CUDA with FP16 support, compiling with torch.CudaHalfTensor
-- CUDA_NVCC_FLAGS: -Xcompiler /wd4819;-DCUDA_HAS_FP16=1
-- Configuring incomplete, errors occurred!

CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/FindCUDA/select_compute_arch.cmake:142 (message):
Unknown CUDA Architecture Name nvcc in CUDA_SELECT_NVCC_ARCH_FLAGS
Call Stack (most recent call first):
lib/THC/CMakeLists.txt:94 (CUDA_SELECT_NVCC_ARCH_FLAGS)

CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/FindCUDA/select_compute_arch.cmake:146 (message):
arch_bin wasn't set for some reason
Call Stack (most recent call first):
lib/THC/CMakeLists.txt:94 (CUDA_SELECT_NVCC_ARCH_FLAGS)

CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/FindCUDA/select_compute_arch.cmake:142 (message):
Unknown CUDA Architecture Name warning in CUDA_SELECT_NVCC_ARCH_FLAGS
Call Stack (most recent call first):
lib/THC/CMakeLists.txt:94 (CUDA_SELECT_NVCC_ARCH_FLAGS)

@BTNC
Copy link
Contributor

BTNC commented Nov 27, 2016

@TyrionLanister , you git cloned old cutorch before this commit. cutorch can only be compiled with msvc since this commit. I suggest you stick with distro way of installation for msvc, since distro refers to the snapshot of torch that can be fully compiled with msvc2015.

To install cutorch (and cunn etc) manually, I suggest you use the code synced by distro, and follow the commands in install.bat

@TyrionLanister
Copy link

TyrionLanister commented Nov 27, 2016

@bntc.
Thanks. I had always used the commit from your latest changes.
image

Look at the error where it shows the build process using internally installed "C:\Program Files\CMake\share\cmake-3.7\Modules\FindCUDA\select_compute_arch.cmake" file so I updated my internal cmake file with your latest commit of "select_compute_arch.cmake"

@BTNC
Copy link
Contributor

BTNC commented Nov 28, 2016

@TyrionLanister , it turns out cmake has introduced the select_compute_arch.cmake file since 3.7 and cutorch is not using its own select_compute_arch.cmake. Thanks for the report.

@etaoinbe
Copy link

On windows7 x64 msvc 10 I got this :

+++++++ Installing common lua packages
Setting environment for using Microsoft Visual Studio 2010 x64 tools.
Setting environment for using Microsoft Visual Studio 2010 x64 tools.
cl /nologo /MD /O2 -c -Fosrc/lfs.obj -IC:/data/git/torch/distro-win/./install/include src/lfs.c
lfs.c
link -dll -def:lfs.def -out:lfs.dll C:/data/git/torch/distro-win/./install/lib/lua51.lib src/lfs.obj
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.

lfs.obj : warning LNK4197: export 'luaopen_lfs' specified multiple times; using first specification
Creating library lfs.lib and object lfs.exp
No existing manifest. Attempting to rebuild...
luafilesystem 1.6.3-1 is now installed in C:\data\git\torch\distro-win.\install\luarocks\systree (license: MIT/X11)

Setting environment for using Microsoft Visual Studio 2010 x64 tools.
Setting environment for using Microsoft Visual Studio 2010 x64 tools.
penlight scm-1 is now installed in C:\data\git\torch\distro-win.\install\luarocks\systree (license: MIT/X11)

fatal: unrecognized input
Setting environment for using Microsoft Visual Studio 2010 x64 tools.
Setting environment for using Microsoft Visual Studio 2010 x64 tools.
cl /nologo /MD /O2 -c -Folua_cjson.obj -IC:/data/git/torch/distro-win/./install/include lua_cjson.c -Dstrncasecmp=_strnicmp -DDISAB
E_INVALID_NUMBERS
lua_cjson.c
cl /nologo /MD /O2 -c -Fostrbuf.obj -IC:/data/git/torch/distro-win/./install/include strbuf.c -Dstrncasecmp=_strnicmp -DDISABLE_INV
LID_NUMBERS
strbuf.c
cl /nologo /MD /O2 -c -Fofpconv.obj -IC:/data/git/torch/distro-win/./install/include fpconv.c -Dstrncasecmp=_strnicmp -DDISABLE_INV
LID_NUMBERS
fpconv.c
link -dll -def:cjson.def -out:cjson.dll C:/data/git/torch/distro-win/./install/lib/lua51.lib lua_cjson.obj strbuf.obj fpconv.obj
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.

lua_cjson.obj : warning LNK4197: export 'luaopen_cjson' specified multiple times; using first specification
Creating library cjson.lib and object cjson.exp
lua_cjson.obj : error LNK2019: unresolved external symbol isnan referenced in function json_append_number
lua_cjson.obj : error LNK2019: unresolved external symbol isinf referenced in function json_append_number
cjson.dll : fatal error LNK1120: 2 unresolved externals

Error: Build error: Failed compiling module cjson.dll
+++++++ Installation error!

@BTNC
Copy link
Contributor

BTNC commented Dec 27, 2016

Hi @etaoinbe , lua-cjson is compiled with the help of this patch and is installed by this line. It is only tested for vs2015. I do not have vs2010 in hand. Please feel free to update that patch to work with vs2010. Please temporarily try BTNC/distro-win in case you were using torch/distro, because latest workable version has not been committed to torch/distro due to one cutorch test error.

@etaoinbe
Copy link

etaoinbe commented Dec 27, 2016

i am already using btnc/distro-win
vs2015 buildtools was worse it complained about windows 10 dlls (on windows 7) so I uninstalled vs2015.

the patch does get applied but linker does not find isnan and isinf

looks like i ran into http://stackoverflow.com/questions/38441740/where-is-isnan-in-msvc-2010

will have another try at vs2015

logfile:

logt7.txt

batchfile that gave above result:

cd \data\git
rmdir /s/q distro-win
git clone https://github.com/BTNC/distro-win.git
cd distro-win
set VisualStudioVersion=10.0
git config apply.whitespace fix
install.bat > c:\temp\logt7.txt 2>&1

@etaoinbe
Copy link

etaoinbe commented Dec 27, 2016

with vs2015 I get failing tests


cmTC_c76c6.exe - System Error

The program can't start because ucrtbased.dll is missing from your computer. Try reinstalling the program to fix this problem.

OK

following is supposed to fix that but it doesnt

https://qualapps.blogspot.be/2016/05/remote-debugging-visual-c-2015.html
https://www.visualstudio.com/downloads/
Remote Tools for Visual Studio 2015 Update 3

Warning: unmatched variable INTEL_MKL_DIR
Warning: unmatched variable INTEL_COMPILER_DIR
cmake -E make_directory build && cd build && cmake .. -DINTEL_MKL_DIR="" -DINTEL_COMPILER_DIR="" -DBLAS_LIBRARIES="C:\Anaconda2
vs\torch-vc14\Library\lib\libopenblas.lib" -DLAPACK_LIBRARIES="C:\Anaconda2\envs\torch-vc14\Library\lib\libopenblas.lib
DLAPACK_FOUND=TRUE -DCMAKE_BUILD_TYPE=Release -DLUA=luajit.exe -DLUALIB=lua51.lib -DLUA_BINDIR="C:/data/git/distro-win/./install/
" -DLUA_INCDIR="C:/data/git/distro-win/./install/include" -DLUA_LIBDIR="C:/data/git/distro-win/./install/lib" -DLUADIR="C:\data\g
distro-win.\install\luarocks\systree/lib/luarocks/rocks/torch/scm-1/lua" -DLIBDIR="C:\data\git\distro-win.\install\luarocks\sys
e/lib/luarocks/rocks/torch/scm-1/lib" -DCMAKE_INSTALL_PREFIX="C:\data\git\distro-win.\install\luarocks\systree/lib/luarocks/rock
orch/scm-1" && nmake

-- Try OpenMP C flag = [/openmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Try OpenMP CXX flag = [/openmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Found OpenMP: /openmp
-- Compiling with OpenMP support
-- Compiling with OpenMP support
-- Could not find hardware support for NEON on this machine.
-- No OMAP3 processor on this on this machine.
-- No OMAP4 processor on this on this machine.
-- Performing Test C_HAS_SSE1_1
-- Performing Test C_HAS_SSE1_1 - Failed
-- Performing Test C_HAS_SSE1_2
-- Performing Test C_HAS_SSE1_2 - Failed
-- Performing Test C_HAS_SSE1_3
-- Performing Test C_HAS_SSE1_3 - Failed
-- Performing Test C_HAS_SSE2_1
-- Performing Test C_HAS_SSE2_1 - Failed
-- Performing Test C_HAS_SSE2_2
-- Performing Test C_HAS_SSE2_2 - Failed
-- Performing Test C_HAS_SSE2_3
-- Performing Test C_HAS_SSE2_3 - Failed
-- Performing Test C_HAS_SSE3_1

blabla...

c:\data\git\distro-win\pkg\torch\lib\th\generic/THTensorConv.c(1000): warning C4244: '=': conversion from 'double' to 'long', possib
le loss of data
c:\data\git\distro-win\pkg\torch\lib\th\generic/THTensorConv.c(1141): warning C4244: '=': conversion from 'double' to 'long', possib
le loss of data
[ 15%] Building C object lib/TH/CMakeFiles/TH.dir/THBlas.c.obj
THBlas.c
[ 18%] Building C object lib/TH/CMakeFiles/TH.dir/THLapack.c.obj
THLapack.c
[ 21%] Building C object lib/TH/CMakeFiles/TH.dir/THLogAdd.c.obj
THLogAdd.c
[ 25%] Building C object lib/TH/CMakeFiles/TH.dir/THRandom.c.obj
THRandom.c
[ 28%] Building C object lib/TH/CMakeFiles/TH.dir/THFile.c.obj
THFile.c
[ 31%] Building C object lib/TH/CMakeFiles/TH.dir/THDiskFile.c.obj
THDiskFile.c
C:\data\git\distro-win\pkg\torch\lib\TH\THDiskFile.c(556): warning C4267: 'function': conversion from 'size_t' to 'int', possible lo
ss of data
[ 34%] Building C object lib/TH/CMakeFiles/TH.dir/THMemoryFile.c.obj
THMemoryFile.c
C:\data\git\distro-win\pkg\torch\lib\TH\THMemoryFile.c(53): warning C4018: '<': signed/unsigned mismatch
C:\data\git\distro-win\pkg\torch\lib\TH\THMemoryFile.c(62): warning C4018: '>': signed/unsigned mismatch
C:\data\git\distro-win\pkg\torch\lib\TH\THMemoryFile.c(308): warning C4018: '<': signed/unsigned mismatch
C:\data\git\distro-win\pkg\torch\lib\TH\THMemoryFile.c(323): warning C4018: '<': signed/unsigned mismatch
C:\data\git\distro-win\pkg\torch\lib\TH\THMemoryFile.c(328): warning C4018: '<': signed/unsigned mismatch
C:\data\git\distro-win\pkg\torch\lib\TH\THMemoryFile.c(333): warning C4018: '<': signed/unsigned mismatch
C:\data\git\distro-win\pkg\torch\lib\TH\THMemoryFile.c(343): warning C4018: '<': signed/unsigned mismatch
C:\data\git\distro-win\pkg\torch\lib\TH\THMemoryFile.c(348): warning C4018: '<': signed/unsigned mismatch
C:\data\git\distro-win\pkg\torch\lib\TH\THMemoryFile.c(489): warning C4018: '<': signed/unsigned mismatch
[ 37%] Building C object lib/TH/CMakeFiles/TH.dir/THAtomic.c.obj
THAtomic.c
C:\data\git\distro-win\pkg\torch\lib\TH\THAtomic.c(18): fatal error C1083: Cannot open include file: 'pthread.h': No such file or di
rectory
NMAKE : fatal error U1077: 'C:\PROGRA2\MICROS3.0\VC\bin\amd64\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.

Error: Build error: Failed building.
+++++++ Installation error!

@BTNC
Copy link
Contributor

BTNC commented Dec 28, 2016

@etaoinbe , you can refer to this patch about how lua-cjson is patched for vs2015, and update it accordingly for vs2010.

According to your logt7.txt file, it seems winedit can not be compiled by vs2010. It is used for trepl package and is not a blocker to use torch.

Regarding missing ucrtbased.dll on win7, I see some references after searched google and here is a link shows some people solved it in different ways.

Regarding the error of THAtomic, I am not using win7 and I am not sure why vs2015 on win7 can have that error. You can check your log (the part you did not paste in your comment) whether it contains Atomics: using MSVC intrinsics or Atomics: using pthread. Furthermore you can update this part to work in your environment with msvc intrinsics.

@etaoinbe
Copy link

logt715.txt

Apparently it is necessary to install full visual studio, command line tools are not enough.

build appears to have succeeded apart from qt stuff. Unfortunately I can not turn off the virusscanner on this laptop.

If I would copy over this buildresult to another machine would you expect it to work as well ?

@BTNC
Copy link
Contributor

BTNC commented Dec 29, 2016

Since all the installation information are stored with full path, it may work if it is copied to the same directory in the other machine with same conda environment setup, however I did not try that.

@etaoinbe
Copy link

the qt stuff compiled after a few more tries, now trying to run a demo

luarocks install nnx
fails with link errors...

nnx.txt

@BTNC
Copy link
Contributor

BTNC commented Dec 29, 2016

@etaoinbe , check this line

@retsyo
Copy link

retsyo commented Apr 6, 2017

so, is there a way to use cutorch in jkjung-avt's windows build?

@hiili
Copy link

hiili commented Jul 27, 2017

I just rebuilt Torch on Windows in both 32-bit and 64-bit configurations and made the resulting binaries available here: https://github.com/hiili/WindowsTorch

To use them, simply download to C:\torch, then run setpaths.cmd and luajit.exe.

These should be fully self-contained builds (tested on two relatively cleanish machines), but I haven’t had an opportunity to test them on a fully clean machine yet. If anyone tries them, then please let us know whether they work. Thanks!

I recorded all commands issued during building into the git logs. ( ping @hughperkins )

@stillcold
Copy link

@hiili
I download your binaries and save it to C:\torch, then I run setpaths.cmd and luajit.exe with Windows 7 command prompt in C:\torch.
Then I type torch.Tensor{1,2,3}, and I got this:
stdin:1: attempt to index global 'torch' (a nil value) stack traceback: stdin:1: in main chunk [C]: at 0x013f922020
Do I miss something?

@hiili
Copy link

hiili commented Jan 17, 2018

@stillcold , you need to require('torch') first. Hope this helps!

cf. hiili/WindowsTorch#4

@stillcold
Copy link

It is works for me! Thanks very much!

@vaclavmuller
Copy link

@ayrtondenner
Copy link

Hello, I downloaded Windows Torch 64-bit version, and manually added paths like shows following image (as setpaths didn't seem to work):

image
image

After doing cd C:\torch\bin\luajit, require('torch') and torch.test(), it seems to work, as the word PASS is printed, though the encoding doesn't shows correctly:

image

But when I try to run it on Visual Studio Code, it doesn't work

image
image

Any ideas about it?

@hiili
Copy link

hiili commented Apr 24, 2018

@ayrtondenner Answered here: hiili/WindowsTorch#4

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

Successfully merging this pull request may close these issues.