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

Torch not found #4

Open
bigHeadsStudio opened this issue Nov 11, 2017 · 16 comments
Open

Torch not found #4

bigHeadsStudio opened this issue Nov 11, 2017 · 16 comments

Comments

@bigHeadsStudio
Copy link

downloaded 64 bits version, ran paths, then ran

luajit, I get some console that says th> but when I try to run torch.Tensor{1,2,3} it says attempt to call global torch. Any ideas :/.

torch

earlier with a totally different branch of torch for windows it couldnt load torch.dll into lua.

@hiili
Copy link
Owner

hiili commented Nov 14, 2017

You need to require('torch') first:

LuaJIT 2.1.0-beta2 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/

 _____              _
|_   _|            | |
  | | ___  _ __ ___| |__
  | |/ _ \| '__/ __| '_ \
  | | (_) | | | (__| | | |
  \_/\___/|_|  \___|_| |_|

JIT: ON SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuse
th> require('torch')
th> torch.test()
Running 154 tests
  1/154 tanh ............................................................ [PASS]
  2/154 testCholesky .................................................... [PASS]
  3/154 multinomialvector ............................................... [PASS]
...

Hope this helps!

@hiili
Copy link
Owner

hiili commented Nov 14, 2017

The first things to check with dll load errors are:

  • Is the dll in a directory listed in your PATH or in the same directory as the calling exe?
  • Are the caller and the dll of the same bitness (eg, both are 64-bit)?

@vaclavmuller
Copy link

vaclavmuller commented Apr 7, 2018

Could somebody help me?
What did I do wrong:

  • I downloaded the WindowsTorch-64-bit_LuaJIT-2-1b2.zip.
  • unpacked whole content to the c:\torch
  • ran the setpaths.cmd
  • ran the c:\torch\bin\luajit.exe
  • wrote this: require('torch')
LuaJIT 2.1.0-beta2 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/

 _____              _
|_   _|            | |
  | | ___  _ __ ___| |__
  | |/ _ \| '__/ __| '_ \
  | | (_) | | | (__| | | |
  \_/\___/|_|  \___|_| |_|

JIT: ON SSE2 SSE3 SSE4.1 BMI2 fold cse dce fwd dse narrow loop abc sink fuse
th> require('torch')
stdin:1: module 'torch' not found:
        no field package.preload['torch']
        no file '.\torch.lua'
        no file 'C:\Torch\bin\lua\torch.lua'
        no file 'C:\Torch\bin\lua\torch\init.lua'
        no file '.\torch.dll'
        no file 'C:\Torch\bin\torch.dll'
        no file 'C:\Torch\bin\loadall.dll'
stack traceback:
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: at 0x7ff66c2e2020
th> help()
stdin:1: attempt to call global 'help' (a nil value)
stack traceback:
        stdin:1: in main chunk
        [C]: at 0x7ff66c2e2020

@vaclavmuller
Copy link

Solution found :-)
setpaths.cmd did not set the system variables, so I did it manually

@ayrtondenner
Copy link

ayrtondenner commented Apr 23, 2018

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 hiili reopened this Apr 24, 2018
@hiili hiili changed the title hello Torch not found Apr 24, 2018
@hiili
Copy link
Owner

hiili commented Apr 24, 2018

@ayrtondenner @vaclavmuller: setpaths.cmd sets the paths only for the command prompt from which it is called, so yes, you have to either issue these commands successively in a single command prompt:

  1. C:\torch\setpaths.cmd
  2. luajit

or you can add the paths permanently to the system paths by yourself.

@ayrtondenner: Are you trying to use Torch in Python? This version is for Lua. You might want to take a look at PyTorch.

@ayrtondenner
Copy link

Didn't know the difference between both versions, sorry. Just installed PyTorch via conda install, now it's working properly, thanks.

@hiili
Copy link
Owner

hiili commented Apr 24, 2018

No problem, glad to hear that you got PyTorch working!

@Saahiljeet-Singh
Copy link

@hiili : Can we set paths such that "th" command is available across different terminal windows ?
As "luajit" is able to open the "th" prompt but my python files are still not able to find the "th" command.

@hiili
Copy link
Owner

hiili commented Jul 3, 2018

@Saahiljeet-Singh: Would it solve your problem if you add the paths manually to your system-wide environment variables?

@wenyi999
Copy link

wenyi999 commented Jun 5, 2019

@hiili hi,same problem here. the 'th' command can't be found and it seems that adding the paths manually to system-wide environment variables doesn't work.

@wenyi999
Copy link

wenyi999 commented Jun 5, 2019

Here is the added system-wide environment variables.
1NIXZ{DJV5M})FIA@XYLZVE
8VK5985)OUI411(R02I XNT

@hiili
Copy link
Owner

hiili commented Jun 5, 2019

Hi! I'm not working on this actively anymore and don't have it on my computer at the moment, so I can't test things on my end unfortunately.

Have you made sure that you have all the vars set that are modified in setpaths.cmd? Also, have you restarted the process (command prompt?) in which you try to use Torch after adding the paths?

@wenyi999
Copy link

wenyi999 commented Jun 5, 2019

I did set all the vars in the setpaths.cmd. And I have tried to restart the process however, the 'th' command can't be found neither before nor after I restart the process. But I can use the 'luajit' command without run the setpaths.cmd now. Does it has the same function with the 'th' command?

@james-zhang-jz
Copy link

Solution found :-)
setpaths.cmd did not set the system variables, so I did it manually

hello,

Weird issue here. if I run the cmd file, then require('torch') returns no error. if i don't, then it return error just like yours. Fun thing here, I have set the system variable manually. and I am fairly sure that I correctly set the variables, any idea?

Thanks,

@james-zhang-jz
Copy link

@ayrtondenner @vaclavmuller: setpaths.cmd sets the paths only for the command prompt from which it is called, so yes, you have to either issue these commands successively in a single command prompt:

  1. C:\torch\setpaths.cmd
  2. luajit

or you can add the paths permanently to the system paths by yourself.

@ayrtondenner: Are you trying to use Torch in Python? This version is for Lua. You might want to take a look at PyTorch.

Hi,

I am using this torch with lua. and my lua file is in D drive as the torch is installed in the C:/torch.
I want to permanently add those variables from the cmd command file but it did not seem to work. I can show you more proof but any idea why at this point?

does the lua file needs to be in the same directory as the torch?

Thanks,

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

7 participants