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

windows env variables #61

Open
Kur-Ich opened this issue Nov 5, 2021 · 5 comments
Open

windows env variables #61

Kur-Ich opened this issue Nov 5, 2021 · 5 comments

Comments

@Kur-Ich
Copy link

Kur-Ich commented Nov 5, 2021

On Windows I've added LIBTORCH and its path to the env variables. I'm getting the following error when I run go get "github.com/sugarme/gotch":

torch_api.cpp:1:9: fatal error: torch/csrc/autograd/engine.h: No such file or directory 1 | #include<torch/csrc/autograd/engine.h> compilation terminated.

What else would be needed? Many thanks!

@sugarme
Copy link
Owner

sugarme commented Nov 6, 2021

@Kur-Ich ,

We haven't got a setup instruction for Windows yet!

There's different libtorch for Windows. You can download from Pytorch site:

and unzip to your system. Then setup environment:

  • Temporary: in your console/shell window
$Env:GOTCH_LIBTORCH = "PATH_TO_YOUR_INSTALLED_LIBTORCH"
$Env:Path += ";PATH_TO_YOUR_INSTALL_LIBTORCH/lib"
  • System-wide: set environment at Control Panel -> System -> Advanced -> Environment Variables

Hope that helps.

@Kur-Ich
Copy link
Author

Kur-Ich commented Nov 6, 2021

Thanks. I've added both but I'm still getting the same error unfortunately. Is anything else needed, such as building the C++ lib with CMake?

@chnykn
Copy link

chnykn commented Mar 2, 2022

Thanks. I've added both but I'm still getting the same error unfortunately. Is anything else needed, such as building the C++ lib with CMake?

I have the same problem on windows

@sugarme
Copy link
Owner

sugarme commented Mar 9, 2022

@Kur-Ich , @chnykn ,

I now can setup a Windows box for testing. Although the issue you mentioned above related to linking issue, it can be fixed by wiring up with absolute path at lib.go file, the compilation still blocked with unsolved issue __assert_fail.... It turns out: Pytorch has not supported MinGW64 GCC at this time while Golang CGO only support MinGW on Window for GCC. So 2 issues to follow up:

  1. Pytorch: [c++] Error Compiling libtorch in Window10, Visual Studio Code pytorch/pytorch#42589
  2. GO: cmd/link: support msvc object files golang/go#20982

Temporary solution for Windows users would be using WSL2 and install a Linux distribution. If you like your Windows system and have Visual Code installed on your Windows, the following steps might help:

  1. Install WSL2 (https://docs.microsoft.com/en-us/windows/wsl/install)
  2. Install Ubuntu on WSL2 (https://www.microsoft.com/en-gb/p/ubuntu-2004-lts/9n6svws3rx71)
  3. Setup visual code for accessing WSL2 (https://code.visualstudio.com/docs/remote/wsl)
  4. Setup Go (install Go on Ubuntu side and set GOPATH environment)
  5. Install tools: sudo apt install build-essential clang
  6. Setup CC to use clang: export CC = clang export CXX = clang++ to fix undefined reference to mkl... at .bashrc (Ubuntu side)
  7. Setup gotch for linux as in README.md file.

Hope that helps.

@chnykn
Copy link

chnykn commented Mar 10, 2022

@sugarme thank you, thank you. I've turned to archlinux.

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

No branches or pull requests

3 participants