torch / distro

Torch installation in a self-contained folder
BSD 3-Clause "New" or "Revised" License
556 stars 484 forks source link

Torch installation in a self-contained folder for windows with msvc #175

Closed BTNC closed 7 years ago

BTNC commented 7 years ago

Hi,

This PR is to get torch installed in a self-contained folder for windows with msvc. The procedure is like the counter party for *nix. Instructions are in README

It works relying on several patches that I think are not best solutions, so I did not send PRs for them.

  1. cunn, cudnn patches are to load THC.dll explicitly instead of using ffi.C directly for windows due to different ffi.load behaviors for different platforms. I think a better solution could be having cutorch.C defined in cutorch to load THC.dll for windows and to refer to ffi.C for *.nix.
  2. cudnn is using LongTensor for size_t which does not work for windows since long is 32bit on windows. The patch does not contain LongTensor replacement, so cudnn can only partially work. I think a better solution is to improve torch integer types so that LongTensor uses int64 for all platforms.

Limitations for msvc users:

  1. Latest torch git sources are not guaranteed to not break msvc compilation since windows is not officially supported. Have to stick with distro stable version.
  2. Type long is used extensively in torch with the assumption that it is 64 bit while long is 32 bit on windows. Be careful with LongTensor.
  3. Only the luajit version can work, lua + luaffifb currently does not work since msvc luaffifb does not work for float argument functions.
  4. Some torch packages in torch luarocks repository can not be installed for windows with 'luarocks install' command, though many requires trivial changes to work on windows.

Followups:

  1. To cleanup the other version of windows installation files.

Great thanks to @howard0su 's review and evaluation.

Thanks,

soumith commented 7 years ago

thanks!