Skip to content

Unable to build torchvision on Windows (installed torch from source and it is running) #4001

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

Closed
dhawals1939 opened this issue Jun 8, 2021 · 7 comments
Labels

Comments

@dhawals1939
Copy link

❓ Questions and Help

I have installed torch successfully in my PC via source, but I am facing this issue while installing the torchvison. I don't think I can install torchvision via pip as it is re-downloading the torch.

Please help me to install it

TIA
i used python setup.py install

Building wheel torchvision-0.9.0a0+01dfa8e
PNG found: True
Running build on conda-build: False
Running build on conda: True
JPEG found: True
Building torchvision with JPEG image support
FFmpeg found: True
Traceback (most recent call last):
  File "C:\Users\dhawals\repos\build_binaries\vision\setup.py", line 472, in <module>
    ext_modules=get_extensions(),
  File "C:\Users\dhawals\repos\build_binaries\vision\setup.py", line 352, in get_extensions
    platform_tag = subprocess.run(
  File "C:\Users\dhawals\miniconda3\lib\subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\dhawals\miniconda3\lib\subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\dhawals\miniconda3\lib\subprocess.py", line 1356, in _execute_child
    args = list2cmdline(args)
  File "C:\Users\dhawals\miniconda3\lib\subprocess.py", line 561, in list2cmdline
    for arg in map(os.fsdecode, seq):
  File "C:\Users\dhawals\miniconda3\lib\os.py", line 822, in fsdecode
    filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType
@datumbox
Copy link
Contributor

datumbox commented Jun 8, 2021

@TheSigmaGuy This is the error that you get if the gcc compiler is not found in the following line:

vision/setup.py

Line 365 in f87ce88

gcc = distutils.spawn.find_executable('gcc')

I would recommend confirming that the gcc compiler is installed on your system. If not you could install it via conda. For more info on how to install TorchVision from source have a look on our guide.

I'll close the ticket to keep things tidy but feel free to reopen if you face more issues.

@datumbox datumbox closed this as completed Jun 8, 2021
@dhawals1939
Copy link
Author

dhawals1939 commented Jun 8, 2021

@datumbox But gcc is for Linux based systems. I am using MSVC Windows system. How can I solve that? I don't think I should install gcc in windows and then compile and torch was compiled with MSVC.

@datumbox
Copy link
Contributor

datumbox commented Jun 8, 2021

@andfoy Do you happen to know if the project can be compiled with ffmpeg support on Windows using a gcc setup like this? Our CI does not currently supports it but I wonder if you have tried it.

@TheSigmaGuy Is it crucial for you to have ffmpeg support? If not you can try disabling it by overwriting the following var to false:

vision/setup.py

Line 348 in f87ce88

has_ffmpeg = ffmpeg_exe is not None

@dhawals1939
Copy link
Author

I installed mingw (I don't have Ninja installed, I don't see it as requirement). Still there is a strange error I see without much detail.

C:\Users\dhawals\repos\build_binaries\vision\torchvision\csrc\io\image\cpu\encode_jpeg.cpp(77): error C2664: 'void jpeg_mem_dest(j_compress_ptr,unsigned char **,size_t *)': cannot convert argument 3 from 'unsigned long *' to 'size_t *'
C:\Users\dhawals\repos\build_binaries\vision\torchvision\csrc\io\image\cpu\encode_jpeg.cpp(77): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Users\dhawals\miniconda3\Library\include\jpeglib.h(979): note: see declaration of 'jpeg_mem_dest'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2

I checked the commit log and found that size_t can be fixed via git checkout 851b623 Also my conda env already had the jpeg installed strangely. I uninstalled it. then ran a clean setup and install.

It worked.

Though the checkout was to may 7th, torchvision version installed on mine seem to be 0.10.axxxx Will it cause any issues?

@datumbox
Copy link
Contributor

datumbox commented Jun 8, 2021

Awesome, thanks for confirming.

The size_t is an unrelated headache as you said. You can read more about it here #3777 (comment). The fix that you quoted is a workaround and we still look for a better fix.

The version should not be an issue. Just make sure you pull the latest master and install the pytorch from nightly as described in our contribution guide.

@andfoy
Copy link
Contributor

andfoy commented Jun 8, 2021

I don't know if we should setup a CI that runs a build using MinGW and not MSVC?

@fmassa
Copy link
Member

fmassa commented Jun 14, 2021

@andfoy PyTorch only builds CI with MSVC, so we should probably keep MSVC as well.

I think we might have some parts in our setup.py for video which might not work well on Windows, we should double-check that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants