WindowsTorch icon indicating copy to clipboard operation
WindowsTorch copied to clipboard

Torch not found

Open bigHeadsStudio opened this issue 7 years ago • 16 comments

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.

bigHeadsStudio avatar Nov 11 '17 22:11 bigHeadsStudio

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 avatar Nov 14 '17 07:11 hiili

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)?

hiili avatar Nov 14 '17 07:11 hiili

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 avatar Apr 07 '18 16:04 vaclavmuller

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

vaclavmuller avatar Apr 07 '18 20:04 vaclavmuller

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?

ayrtondenner avatar Apr 23 '18 13:04 ayrtondenner

@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.

hiili avatar Apr 24 '18 09:04 hiili

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

ayrtondenner avatar Apr 24 '18 17:04 ayrtondenner

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

hiili avatar Apr 24 '18 20:04 hiili

@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.

Saahiljeet-Singh avatar Jun 28 '18 11:06 Saahiljeet-Singh

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

hiili avatar Jul 03 '18 16:07 hiili

@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 avatar Jun 05 '19 10:06 wenyi999

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

wenyi999 avatar Jun 05 '19 10:06 wenyi999

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?

hiili avatar Jun 05 '19 15:06 hiili

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?

wenyi999 avatar Jun 05 '19 16:06 wenyi999

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 avatar Jul 30 '20 05:07 james-zhang-jz

@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,

james-zhang-jz avatar Jul 30 '20 05:07 james-zhang-jz