在装有VS2013 x64或VS2017 x64的Windows 10上安装LuaJIT LuaRocks Torch7(在Torch7失败)

时间:2019-07-23 22:02:12

标签: windows lua torch luajit luarocks

过去3天,我努力在新的Windows 10笔记本电脑上安装Lua with Torch。阅读了很多关于该主题的堆栈溢出文章后,我认为我最好的选择是严格遵循Siavash Gorji的说明-参见:https://libraries.io/github/SiavashGorji/LuaJIT-Luarocks-Torch7

LuaJIT和LuaRocks安装正常,但是“ luarocks install torch”命令失败(使用VS2013 x64或VS2017 x64构建torch7时失败)。

首先,即使LuaJIT和LuaRocks都成功构建并运行,这也是第一个cmake输出的内容:

(no source code here, just compiler outputs)

D:\luainstall-64\build>cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%LuaJIT-Luarocks-Torch7_ROOT%\install
-- The C compiler identification is MSVC 18.0.40629.0
-- The CXX compiler identification is MSVC 18.0.40629.0
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is MSVC
-- Found assembler: D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Looking for sin in m
-- Looking for sin in m - not found
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Performing Test LJ_TARGET_X64
-- Performing Test LJ_TARGET_X64 - Success
-- LuaJIT Target: x64
-- LuaJIT target x64
-- Performing Test LJ_ARCH_BITS_64
-- Performing Test LJ_ARCH_BITS_64 - Success
-- Performing Test LJ_HASJIT_1
-- Performing Test LJ_HASJIT_1 - Success
-- Performing Test LJ_HASFFI_1
-- Performing Test LJ_HASFFI_1 - Success
-- Performing Test LJ_DUALNUM_1
-- Performing Test LJ_DUALNUM_1 - Failed
-- Performing Test LJ_ARCH_HASFPU_1
-- Performing Test LJ_ARCH_HASFPU_1 - Success
-- Performing Test LJ_ABI_SOFTFP_1
-- Performing Test LJ_ABI_SOFTFP_1 - Failed
-- Looking for sin in m
-- Looking for sin in m - not found
-- Configuring done
-- Generating done
-- Build files have been written to: D:/luainstall-64/build



And last, when Torch7 build problem occurs, I have this (partial) output (focusing on things that may cause of the problem):

D:\luainstall-64\build>luarocks install torch

D:\luainstall-64\build>rem=rem --[[
Installing https://raw.githubusercontent.com/torch/rocks/master/torch-scm-1.rockspec...
Using https://raw.githubusercontent.com/torch/rocks/master/torch-scm-1.rockspec... switching to 'build' mode
Cloning into 'torch7'...
remote: Enumerating objects: 181, done.
remote: Counting objects: 100% (181/181), done.
remote: Compressing objects: 100% (174/174), done.
Receiving objects: 100% (181/181), 335.48 KiB | 1.00 MiB/s, done.ceiving objects:  98% (178/181)

Resolving deltas: 100% (8/8), done.
cmake -E make_directory build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DLUA=D:/luainstall-64/install/./luajit -DLUALIB=libluajit.lib -DLUA_BINDIR="D:/luainstall-64/install/." -DLUA_INCDIR="D:/luainstall-64/install/include" -DLUA_LIBDIR="D:/luainstall-64/install/." -DLUADIR="D:/luainstall-64/install/luarocks/torch/scm-1/lua" -DLIBDIR="D:/luainstall-64/install/luarocks/torch/scm-1/lib" -DCMAKE_INSTALL_PREFIX="D:/luainstall-64/install/luarocks/torch/scm-1" && nmake


D:\Users\docte\AppData\Local\Temp\luarocks_torch-scm-1-1820\torch7>if -E == -E (cmake.exe  -E make_directory build  )  else (cmake.exe -G "NMake Makefiles"  -DWIN32=1  -E make_directory build )

D:\Users\docte\AppData\Local\Temp\luarocks_torch-scm-1-1820\torch7\build>if .. == -E (cmake.exe  .. -DCMAKE_BUILD_TYPE=Release -DLUA=D:/luainstall-64/install/./luajit -DLUALIB=libluajit.lib -DLUA_BINDIR="D:/luainstall-64/install/." -DLUA_INCDIR="D:/luainstall-64/install/include" -DLUA_LIBDIR="D:/luainstall-64/install/." -DLUADIR="D:/luainstall-64/install/luarocks/torch/scm-1/lua" -DLIBDIR="D:/luainstall-64/install/luarocks/torch/scm-1/lib" -DCMAKE_INSTALL_PREFIX="D:/luainstall-64/install/luarocks/torch/scm-1"  )  else (cmake.exe -G "NMake Makefiles"  -DWIN32=1  .. -DCMAKE_BUILD_TYPE=Release -DLUA=D:/luainstall-64/install/./luajit -DLUALIB=libluajit.lib -DLUA_BINDIR="D:/luainstall-64/install/." -DLUA_INCDIR="D:/luainstall-64/install/include" -DLUA_LIBDIR="D:/luainstall-64/install/." -DLUADIR="D:/luainstall-64/install/luarocks/torch/scm-1/lua" -DLIBDIR="D:/luainstall-64/install/luarocks/torch/scm-1/lib" -DCMAKE_INSTALL_PREFIX="D:/luainstall-64/install/luarocks/torch/scm-1" )
-- The C compiler identification is MSVC 18.0.40629.0
-- The CXX compiler identification is MSVC 18.0.40629.0
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -openmp (found version "2.0")
-- Found OpenMP_CXX: -openmp (found version "2.0")
-- Found OpenMP: TRUE (found version "2.0")
-- Compiling with OpenMP support
CMake Deprecation Warning at lib/TH/CMakeLists.txt:5 (CMAKE_POLICY):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Compiling with OpenMP support
-- Could not find hardware support for NEON on this machine.
-- No OMAP3 processor on this machine.
-- No OMAP4 processor on this machine.
-- Looking for cpuid.h
-- Looking for cpuid.h - not found
-- Performing Test NO_GCC_EBX_FPIC_BUG
-- Performing Test NO_GCC_EBX_FPIC_BUG - Failed
-- Performing Test C_HAS_SSE1_1
-- Performing Test C_HAS_SSE1_1 - Success
-- Performing Test C_HAS_SSE2_1
-- Performing Test C_HAS_SSE2_1 - Success
-- Performing Test C_HAS_SSE3_1
-- Performing Test C_HAS_SSE3_1 - Success
-- Performing Test C_HAS_SSE4_1_1
-- Performing Test C_HAS_SSE4_1_1 - Success
-- Performing Test C_HAS_SSE4_2_1
-- Performing Test C_HAS_SSE4_2_1 - Success
-- Performing Test C_HAS_AVX_1
-- Performing Test C_HAS_AVX_1 - Success
-- Performing Test C_HAS_AVX2_1
-- Performing Test C_HAS_AVX2_1 - Success
-- Performing Test CXX_HAS_SSE1_1
-- Performing Test CXX_HAS_SSE1_1 - Success
-- Performing Test CXX_HAS_SSE2_1
-- Performing Test CXX_HAS_SSE2_1 - Success
-- Performing Test CXX_HAS_SSE3_1
-- Performing Test CXX_HAS_SSE3_1 - Success
-- Performing Test CXX_HAS_SSE4_1_1
-- Performing Test CXX_HAS_SSE4_1_1 - Success
-- Performing Test CXX_HAS_SSE4_2_1
-- Performing Test CXX_HAS_SSE4_2_1 - Success
-- Performing Test CXX_HAS_AVX_1
-- Performing Test CXX_HAS_AVX_1 - Success
-- Performing Test CXX_HAS_AVX2_1
-- Performing Test CXX_HAS_AVX2_1 - Success
-- SSE2 Found
-- SSE3 Found
-- AVX Found
-- AVX2 Found
-- Performing Test HAS_C11_ATOMICS
-- Performing Test HAS_C11_ATOMICS - Failed
-- Performing Test HAS_MSC_ATOMICS
-- Performing Test HAS_MSC_ATOMICS - Success
-- Performing Test HAS_GCC_ATOMICS
-- Performing Test HAS_GCC_ATOMICS - Failed
-- TH_SO_VERSION: 0
-- Atomics: using MSVC intrinsics
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core - libiomp5md - pthread]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_intel_thread - mkl_core - libiomp5md - pthread]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core - pthread]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_intel_thread - mkl_core - pthread]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_sequential - mkl_core]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_sequential - mkl_core]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_sequential - mkl_core]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_sequential - mkl_core]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core - libiomp5md - pthread]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_intel_thread - mkl_core - libiomp5md - pthread]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core - pthread]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_intel_thread - mkl_core - pthread]
--   Library mkl_intel: not found
-- Checking for [mkl - guide - pthread - m]
--   Library mkl: not found
-- MKL library not found
-- Checking for [openblas]
--   Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
-- Checking for [openblas - pthread]
--   Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
-- Checking for [libopenblas]
--   Library libopenblas: BLAS_libopenblas_LIBRARY-NOTFOUND
-- Checking for [goto2 - gfortran]
--   Library goto2: BLAS_goto2_LIBRARY-NOTFOUND
-- Checking for [goto2 - gfortran - pthread]
--   Library goto2: BLAS_goto2_LIBRARY-NOTFOUND
-- Checking for [acml - gfortran]
--   Library acml: BLAS_acml_LIBRARY-NOTFOUND
-- Checking for [Accelerate]
--   Library Accelerate: BLAS_Accelerate_LIBRARY-NOTFOUND
-- Checking for [vecLib]
--   Library vecLib: BLAS_vecLib_LIBRARY-NOTFOUND
-- Checking for [ptf77blas - atlas - gfortran]
--   Library ptf77blas: BLAS_ptf77blas_LIBRARY-NOTFOUND
-- Checking for [blas]
--   Library blas: BLAS_blas_LIBRARY-NOTFOUND
-- Cannot find a library with BLAS API. Not using BLAS.
-- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core - libiomp5md - pthread]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_intel_thread - mkl_core - libiomp5md - pthread]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core - pthread]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_intel_thread - mkl_core - pthread]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_sequential - mkl_core]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_sequential - mkl_core]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_sequential - mkl_core]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_sequential - mkl_core]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core - libiomp5md - pthread]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_intel_thread - mkl_core - libiomp5md - pthread]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core - pthread]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_intel_thread - mkl_core - pthread]
--   Library mkl_intel: not found
-- Checking for [mkl - guide - pthread - m]
--   Library mkl: not found
-- MKL library not found
-- Checking for [openblas]
--   Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
-- Checking for [openblas - pthread]
--   Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
-- Checking for [libopenblas]
--   Library libopenblas: BLAS_libopenblas_LIBRARY-NOTFOUND
-- Checking for [goto2 - gfortran]
--   Library goto2: BLAS_goto2_LIBRARY-NOTFOUND
-- Checking for [goto2 - gfortran - pthread]
--   Library goto2: BLAS_goto2_LIBRARY-NOTFOUND
-- Checking for [acml - gfortran]
--   Library acml: BLAS_acml_LIBRARY-NOTFOUND
-- Checking for [Accelerate]
--   Library Accelerate: BLAS_Accelerate_LIBRARY-NOTFOUND
-- Checking for [vecLib]
--   Library vecLib: BLAS_vecLib_LIBRARY-NOTFOUND
-- Checking for [ptf77blas - atlas - gfortran]
--   Library ptf77blas: BLAS_ptf77blas_LIBRARY-NOTFOUND
-- Checking for [blas]
--   Library blas: BLAS_blas_LIBRARY-NOTFOUND
-- Cannot find a library with BLAS API. Not using BLAS.
-- LAPACK requires BLAS
-- Cannot find a library with LAPACK API. Not using LAPACK.
-- Performing Test C_HAS_THREAD
-- Performing Test C_HAS_THREAD - Success
CMake Deprecation Warning at lib/luaT/CMakeLists.txt:3 (CMAKE_POLICY):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Configuring done
-- Generating done
-- Build files have been written to: D:/Users/docte/AppData/Local/Temp/luarocks_torch-scm-1-1820/torch7/build

Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.

Scanning dependencies of target TH
[  2%] Building C object lib/TH/CMakeFiles/TH.dir/THGeneral.c.obj
THGeneral.c
[  5%] Building C object lib/TH/CMakeFiles/TH.dir/THHalf.c.obj
THHalf.c
[  7%] Building C object lib/TH/CMakeFiles/TH.dir/THAllocator.c.obj
THAllocator.c
[ 10%] Building C object lib/TH/CMakeFiles/TH.dir/THSize.c.obj
THSize.c
[ 12%] Building C object lib/TH/CMakeFiles/TH.dir/THStorage.c.obj
THStorage.c
D:\Users\docte\AppData\Local\Temp\luarocks_torch-scm-1-1820\torch7\lib\TH\THStorage.c(18) : warning C4244: 'function' : conversion from 'const ptrdiff_t' to 'const long', possible loss of data

Now skipping some compiler warnings ...

d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\generic/simd/simd.h(100) : error C2054: expected '(' to follow 'inline'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\generic/simd/simd.h(101) : error C2085: 'cpuid' : not in formal parameter list
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\generic/simd/simd.h(101) : error C2143: syntax error : missing ';' before '{'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\generic/simd/simd.h(123) : error C2054: expected '(' to follow 'inline'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\generic/simd/simd.h(124) : error C2085: 'detectHostSIMDExtensions' : not in formal parameter list
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\generic/simd/simd.h(124) : error C2143: syntax error : missing ';' before '{'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(4) : error C2054: expected '(' to follow 'inline'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(4) : error C2085: 'TH_sigmoid' : not in formal parameter list
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(4) : error C2143: syntax error : missing ';' before '{'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(8) : error C2054: expected '(' to follow 'inline'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(8) : error C2085: 'TH_frac' : not in formal parameter list
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(8) : error C2143: syntax error : missing ';' before '{'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(12) : error C2054: expected '(' to follow 'inline'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(12) : error C2085: 'TH_rsqrt' : not in formal parameter list
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(12) : error C2143: syntax error : missing ';' before '{'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(16) : error C2054: expected '(' to follow 'inline'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(16) : error C2085: 'TH_lerp' : not in formal parameter list
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(16) : error C2143: syntax error : missing ';' before '{'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(20) : error C2054: expected '(' to follow 'inline'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(20) : error C2085: 'TH_sigmoidf' : not in formal parameter list
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(20) : error C2143: syntax error : missing ';' before '{'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(24) : error C2054: expected '(' to follow 'inline'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(24) : error C2085: 'TH_fracf' : not in formal parameter list
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(24) : error C2143: syntax error : missing ';' before '{'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(28) : error C2054: expected '(' to follow 'inline'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(28) : error C2085: 'TH_rsqrtf' : not in formal parameter list
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(28) : error C2143: syntax error : missing ';' before '{'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(32) : error C2054: expected '(' to follow 'inline'
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(32) : error C2085: 'TH_lerpf' : not in formal parameter list
d:\users\docte\appdata\local\temp\luarocks_torch-scm-1-1820\torch7\lib\th\THMath.h(32) : error C2143: syntax error : missing ';' before '{'

skipping some warnings ...


NMAKE : fatal error U1077: '"D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\cl.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.

Error: Build error: Failed building.

D:\luainstall-64\build>

我知道Windows还没有正式支持Torch7,但是如果我们有一个成功的解决方案,它将对社区有很大的帮助。我肯定会在整整一周的时间里取得成功,但是在一些Torch7依赖专家的帮助下,我需要踢一两次,这可以帮助我专注于此阶段的强制性工作。

如果我们使它在Windows 10下运行,无论是使用MSVC还是MinGW,对于Lua Windows社区来说都是成功的!!

1 个答案:

答案 0 :(得分:0)

确定Microsoft Windows 10用户。我使用VS2013 x64解决了这个惊人的安装/配置/重新编译难题(使用VS2017甚至是VS2019,很可能会成功)。该解决方案基于Siavash Gorji的说明-请参阅:https://libraries.io/github/SiavashGorji/LuaJIT-Luarocks-Torch7,我一步一步地遵循,同时保留了我必须做的所有事情的准确而详细的日志。

今天,我必须继续安装可选的但对于执行速度很重要的东西,即安装(重新编译)NVIDIA CUDA软件层(割草机,cunn,cunnx和cudnn模块)。我将在今天晚些时候在此处发布这些其他步骤。

-1)今天,我确实为VS2013和VS2017安装安装了完整的英特尔MKL库。

0)现在,重新启动后,这是尝试使用VS2013 x64本机工具命令提示符成功安装LuaJIT-Luarocks-Torch7

0.5)要这次检测到英特尔MKL库,请为此VS2013 x64本机工具命令提示符设置环境变量 由https://software.intel.com/en-us/mkl-windows-developer-guide-setting-environment-variables指定 和https://software.intel.com/en-us/mkl/choose-download/windows

处的英特尔MKL库安装说明
cd "D:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019\windows\mkl\bin"
d:
mklvars.bat intel64

1)然后,我们重新构建LuaJIT-Luarocks(这次希望看到Intel MKL库):

cd D:\luainstall-64\build
d:
cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%LuaJIT-Luarocks-Torch7_ROOT%\install
nmake
cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%LuaJIT-Luarocks-Torch7_ROOT%\install -P cmake_install.cmake

2)已经安装了岩石包裹物和路径,因此请继续尝试安装luockcks安装割炬

luarocks list

luarocks install torch

但是,“ luarocks install torch”返回错误,从未定义“ inline”开始, 内联是c99关键字,MSVC(参考http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx)尚未(完全)支持c99。

我们可以定义:

-Dinline=__inline

要这样做:

cd D:\luainstall-64\install\luarocks
d:
luarocks download torch

edit rockspec file D:\luainstall-64\install\luarocks\torch-scm-1.rockspec
add -Dinline=__inline (let's say after "cmake -E make_directory build && cd build && cmake .. " and before "-DCMAKE_BUILD_TYPE=Release -DLUA=$(LUA) -DLUALIB=$(LUALIB) -DLUA_BINDIR="$(LUA_BINDIR)" -DLUA_INCDIR="$(LUA_INCDIR)" -DLUA_LIBDIR="$(LUA_LIBDIR)" -DLUADIR="$(LUADIR)" -DLIBDIR="$(LIBDIR)" -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE)")
luarocks unpack torch-scm-1.rockspec
cd torch-scm-1\torch7
edit CMakeLists.txt

因此“使用MSVC时的标志”部分如下所示:

# Flags
# When using MSVC
IF(MSVC)
  # we want to respect the standard, and we are bored of those **** .
  ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE=1)
  # spi, begin
  # "luarocks install torch" returns error, starting with "inline" not being defined,
  # inline is a c99 keyword and c99 is not yet (fully) supported with MSVC (ref. http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx).
  ADD_DEFINITIONS(-Dinline=__inline)
  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FORCE")
  SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /FORCE")
  # spi, end
ENDIF(MSVC)

现在,准备使用以下语言进行构建:

luarocks make ..\..\torch-scm-1.rockspec

最后,“羽毛球火炬安装”成功了!

要测试割炬的安装,我们可以通过以下常规命令提示符创建并显示2x3x4随机初始化的张量:

luajit
require "torch"
print(torch.Tensor(2,3,4))

有效!

最后,将Torch_DIR设置为LuaJIT-Luarocks-Torch7_ROOT%\ share \ cmake \ torch目录的环境变量:

setx Torch_DIR %LuaJIT-Luarocks-Torch7_ROOT%\share\cmake\torch
(for me, I edit the system environment variables from the controlpanel, adding Torch_DIR D:\luainstall-64\share\cmake\torch)

因此,因此,我必须关闭VS2013 x64本机工具命令提示符 然后重新打开新的VS2013 x64本机工具命令提示符

cd "D:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019\windows\mkl\bin"
d:
mklvars.bat intel64

现在,安装割炬模块:

在Unix环境中安装手电筒时,它将自动安装“很多好东西”。在以下部分中,我们尝试使用luarocks安装程序一个接一个地安装它们(即大多数)。尝试按照此处介绍的相同顺序安装它们。要在Windows上安装一些包含C代码的lua / torch模块,我们需要对其进行一些更改(因为我们基本上是从Linux移植它们)。您可以在“%LuaJIT-Luarocks-Torch7_ROOT%”的附加文件夹中找到所有这些编辑后的模块。要安装这些模块,我们将使用luockcks本地安装功能(即使用“ luarocks make”代替“ luarocks install”)。如下所示,我们需要做的就是将NTCP cd到每个模块的主目录,然后运行“ luarocks make path-to-module-rockspec-file”。

luarocks install luafilesystem
luarocks install penlight

cd %LuaJIT-Luarocks-Torch7_ROOT%\extra\lua-cjson
(for me, cd D:\luainstall-64\extra\lua-cjson)
luarocks make lua-cjson-2.1devel-1.rockspec

cd %LuaJIT-Luarocks-Torch7_ROOT%\extra\luaffifb
(for me, cd D:\luainstall-64\extra\luaffifb)
luarocks make luaffi-scm-1.rockspec

luarocks install sundown
luarocks install dok

cd %LuaJIT-Luarocks-Torch7_ROOT%\extra\sys
(for me, cd D:\luainstall-64\extra\sys)
luarocks make sys-1.1-0.rockspec

luarocks install xlua

但是“ luarocks install nn”没有通过,需要进行luarocks下载,解压缩luarocks和进行luockcks制作:

cd D:\luainstall-64\install\luarocks
d:
luarocks download nn
edit rockspec file D:\luainstall-64\install\luarocks\nn-scm-1.rockspec
add -Dinline=__inline
luarocks unpack nn-scm-1.rockspec
cd nn-scm-1\nn
edit CMakeLists.txt

因此“使用MSVC时的标志”部分如下所示:

# Flags
# When using MSVC
IF(MSVC)
  # we want to respect the standard, and we are bored of those **** .
  ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE=1)
  # spi, begin
  # "luarocks install nn" returns error, starting with "inline" not being defined,
  # inline is a c99 keyword and c99 is not yet (fully) supported with MSVC (ref. http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx).
  ADD_DEFINITIONS(-Dinline=__inline)
  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FORCE")
  SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /FORCE")
  # spi, end
ENDIF(MSVC)

现在,准备使用以下语言进行构建:

rename D:\luainstall-64\install\luarocks\nn nn-backup
luarocks make ..\..\nn-scm-1.rockspec

由于

未能建立nn
d:\luainstall-64\install\luarocks\nn-scm-1\nn\lib\thnn\generic/FeatureLPPooling.c(214) : error C2143: syntax error : missing ';' before 'type'
unsigned type not supported in openmp 2.0 (which is the version msvc 2013 supports), 
so, for 2 blocks of code in FeatureLPPooling.c, I replaced the type size_t by long (within the 2 pragma omp parallel for blocks of code)
also, not declaring any counter variables within for statement (within the pragma omp parallel for here below, 
moving counter variables declaration before each for loop

试图建立nn

cd D:\luainstall-64\install\luarocks\nn-scm-1\nn
d:
luarocks make ..\..\nn-scm-1.rockspec

构建成功!!!

luarocks install graph
luarocks install nngraph

,但是“羽扇形安装映像”没有通过 -无法找到JPEG(缺少:JPEG_LIBRARY JPEG_INCLUDE_DIR) -找不到ZLIB(丢失:ZLIB_LIBRARY ZLIB_INCLUDE_DIR) -找不到PNG(丢失:PNG_LIBRARY PNG_PNG_INCLUDE_DIR) 因此,请参见https://devblogs.microsoft.com/cppblog/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows/

Clone from GitHub: git clone https://github.com/Microsoft/vcpkg
Run the bootstrap script in the vcpkg folder:
D:\vcpkg> .\bootstrap-vcpkg.bat
d:\vcpkg>vcpkg integrate install

为此vcpkg根应用了用户范围的集成。

d:\vcpkg>vcpkg install openjpeg:x64-windows
d:\vcpkg>vcpkg install zlib:x64-windows

zlib安装失败

vcpkg update

重试zlib安装

d:\vcpkg>vcpkg install zlib:x64-windows

zlib安装成功

d:\vcpkg>vcpkg install libpng:x64-windows

libpng安装未成功 重试

d:\vcpkg>vcpkg install libpng:x64-windows

libpng安装成功

现在,重试安装“ luarocks安装映像”

luarocks install image

它没有通过 -无法找到JPEG(缺少:JPEG_LIBRARY JPEG_INCLUDE_DIR) -找不到ZLIB(丢失:ZLIB_LIBRARY ZLIB_INCLUDE_DIR) -找不到PNG(丢失:PNG_LIBRARY PNG_PNG_INCLUDE_DIR) 设置以下6个环境变量:

JPEG_LIBRARY D:\vcpkg\packages\openjpeg_x64-windows\lib
JPEG_INCLUDE_DIR D:\vcpkg\packages\openjpeg_x64-windows\include
ZLIB_LIBRARY D:\vcpkg\packages\zlib_x64-windows\lib
ZLIB_INCLUDE_DIR D:\vcpkg\packages\zlib_x64-windows\include
PNG_LIBRARY D:\vcpkg\packages\libpng_x64-windows\lib
PNG_PNG_INCLUDE_DIR D:\vcpkg\packages\libpng_x64-windows\include

(对我来说,我是从控制面板编辑系统环境变量的) 因此,因此,我必须关闭VS2013 x64本机工具命令提示符 然后重新打开新的VS2013 x64本机工具命令提示符

cd "D:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019\windows\mkl\bin"
d:
mklvars.bat intel64
cd D:\luainstall-64\install\luarocks
d:

现在,重试安装“ luarocks安装映像”

luarocks install image

(2019july25,12h56am)“孔雀安装图像”仍然看不到jpeg,zlib和png库

因此,“羽毛球安装映像”不会通过,需要进行羽毛球下载,将羽毛球解压缩,并将羽毛球制作为:

cd D:\luainstall-64\install\luarocks
d:
luarocks download image
edit rockspec file D:\luainstall-64\install\luarocks\image-1.1.alpha-0.rockspec

将此定义添加到cmake命令:

"-DCMAKE_TOOLCHAIN_FILE=d:/vcpkg/scripts/buildsystems/vcpkg.cmake"
i.e. cmake -DCMAKE_TOOLCHAIN_FILE=d:/vcpkg/scripts/buildsystems/vcpkg.cmake
add also -Dinline=__inline to this cmake command
also add -DJPEG_LIBRARY=D:/vcpkg/packages/openjpeg_x64-windows/lib
along with -DJPEG_INCLUDE_DIR=D:/vcpkg/packages/openjpeg_x64-windows/include
luarocks unpack image-1.1.alpha-0.rockspec
cd image-1.1.alpha-0/image
edit CMakeLists.txt

在顶部,在FIND_PACKAGE语句之后,添加此行

ADD_DEFINITIONS(-Dinline=__inline)

现在,准备使用以下语言进行构建:

rename D:\luainstall-64\install\luarocks\image image-backup
luarocks make ..\..\image-1.1.alpha-0.rockspec

这次,构建成功,但是仍然没有找到jpeg库 因此,在顶部,在FIND_PACKAGE语句和上一个

之后
ADD_DEFINITIONS(-Dinline=__inline) statement ...

添加此行

ADD_DEFINITIONS(-DJPEG_LIBRARY="D:/vcpkg/packages/openjpeg_x64-windows/lib")

添加此行

ADD_DEFINITIONS(-DJPEG_INCLUDE_DIR="D:/vcpkg/packages/openjpeg_x64-windows/include")

现在,准备使用以下命令再次构建:

luarocks make ..\..\image-1.1.alpha-0.rockspec

好的,这一次代码正在寻找的头文件jpeglib.h不在openjpeg库中 在撰写本文时,Microsoft vcpkg无法安装libjpeg,也无法成功安装libjpeg-turbo 因此,我直接从https://sourceforge.net/projects/libjpeg-turbo/files/2.0.0/libjpeg-turbo-2.0.0-vc64.exe/download下载libjpeg-turbo 并安装并修改(再次编辑)与libjpeg相关的环境变量(使用Controlpanel环境变量编辑器)

JPEG_LIBRARY D:\libjpeg-turbo64\lib
JPEG_INCLUDE_DIR D:\libjpeg-turbo64\include

再次,让我们编辑rockspec文件

edit D:\luainstall-64\install\luarocks\image-1.1.alpha-0.rockspec

并修改(更改)与libjpeg相关的定义,以安全起见,用斜杠证明通往libjpeg-turbo文件夹的新路径

-DJPEG_LIBRARY=D:/libjpeg-turbo64/lib/jpeg.lib 
-DJPEG_LIBRARY2=D:/libjpeg-turbo64/lib/turbojpeg.lib 
-DJPEG_INCLUDE_DIR=D:/libjpeg-turbo64/include

现在,让我们再做一次

cd D:\luainstall-64\install\luarocks
d:
luarocks unpack image-1.1.alpha-0.rockspec
cd image-1.1.alpha-0/image
edit CMakeLists.txt

在顶部,在FIND_PACKAGE语句之后,添加此行

ADD_DEFINITIONS(-Dinline=__inline)

添加此行

ADD_DEFINITIONS(-DJPEG_LIBRARY="D:/libjpeg-turbo64/lib/jpeg.lib")

添加此行

ADD_DEFINITIONS(-DJPEG_LIBRARY2="D:/libjpeg-turbo64/lib/turbojpeg.lib")

添加此行

ADD_DEFINITIONS(-DJPEG_INCLUDE_DIR="D:/libjpeg-turbo64/include")

并在“ if(JPEG_FOUND)”块中,替换下面的两行

替换

SET(CMAKE_REQUIRED_LIBRARIES "${JPEG_LIBRARY}")

SET(CMAKE_REQUIRED_LIBRARIES "${JPEG_LIBRARY} ${JPEG_LIBRARY2}")

并替换

TARGET_LINK_LIBRARIES(jpeg luaT TH ${JPEG_LIBRARIES})

使用

TARGET_LINK_LIBRARIES(jpeg luaT TH ${JPEG_LIBRARIES} ${JPEG_LIBRARY} ${JPEG_LIBRARY2})

现在,准备使用以下命令再次构建:

luarocks make ..\..\image-1.1.alpha-0.rockspec

cd D:\luainstall-64\install\luarocks
d:
luarocks install optim
luarocks install gnuplot
luarocks install env

cd %LuaJIT-Luarocks-Torch7_ROOT%\extra\nnx
luarocks make nnx-0.1-1.rockspec

luarocks install graphicsmagick
luarocks install argcheck
luarocks install fftw3

cd %LuaJIT-Luarocks-Torch7_ROOT%\extra\torch-signal
luarocks make ./rocks/signal-scm-1.rockspec



luarocks install class
luarocks install rational
luarocks install cairo

cd %LuaJIT-Luarocks-Torch7_ROOT%\extra\luasocket
luarocks make ./rockspec/luasocket-3.0rc2-1.rockspec

好的,到目前为止成功

找到完整解决方案的第一部分!

如果您想复制其中的某些内容,请参阅下面的参考部分,以了解到今天的情况。

干杯

Steph

供参考:(前一天,我开始执行这些步骤)

1)安装(Windows 64位)

我选择安装在:

D:\luainstall-64

设置环境变量:

LuaJIT-Luarocks-Torch7_ROOT D:\luainstall-64 

在Windows上-在适当的环境中使用命令提示符(我使用VS2013 x64本机工具命令提示符)

cd %LuaJIT-Luarocks-Torch7_ROOT%\..
git clone https://github.com/SiavashGorji/LuaJIT-Luarocks-Torch7.git
cd %LuaJIT-Luarocks-Torch7_ROOT%
mkdir build
cd build

cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%LuaJIT-Luarocks-Torch7_ROOT%\install
nmake
cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%LuaJIT-Luarocks-Torch7_ROOT%\install -P cmake_install.cmake


setx path "%LuaJIT-Luarocks-Torch7_ROOT%\install;%path%"
D:\luainstall-64\install

setx LUA_PATH .\?.lua;C:\Programs\LuaJIT-Luarocks-Torch7\install\lua\?.lua;C:\Programs\LuaJIT-Luarocks-Torch7\install\lua\?\init.lua;
set LUA_PATH .\?.lua;D:\luainstall-64\install\lua\?.lua;D:\luainstall-64\install\lua\?\init.lua;

setx LUA_CPATH .\?.dll;C:\Programs\LuaJIT-Luarocks-Torch7\install\?.dll;C:\Programs\LuaJIT-Luarocks-Torch7\install\loadall.dll
set LUA_CPATH .\?.dll;D:\luainstall-64\install\?.dll;D:\luainstall-64\install\loadall.dll

setx LUA_DEV %LuaJIT-Luarocks-Torch7_ROOT%\install

重要说明: 请注意,在安装目录中,有一个cmake.cmd,该文件会自动附加带有-G“ NMake Makefiles”标志的任何cmake命令(被luarocks调用)。为了使它起作用,您应确保安装目录在cmake安装目录之前。 因此,我确实将D:\ luainstall-64 \ install首先放在系统路径中(在cmake路径之前)。

2)Torch7(Windows 64位)

在Windows上-在适当的环境中使用命令提示符(我使用VS2013 x64本机工具命令提示符)

luarocks install cwrap

luarocks install paths

luarocks install torch

但是在luacocks安装火炬期间出现错误:

[ 61%] Generating TensorMath.c
NMAKE : fatal error U1077: 'D:\luainstall-64\install\luajit.EXE' : return code '0xc0000005'
Stop.
NMAKE : fatal error U1077: '"D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.

Error: Build error: Failed building.