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

Installation on Windows 10 #63

Closed
nicost opened this issue Jan 20, 2022 · 3 comments · Fixed by #93
Closed

Installation on Windows 10 #63

nicost opened this issue Jan 20, 2022 · 3 comments · Fixed by #93

Comments

@nicost
Copy link

nicost commented Jan 20, 2022

All goes well (after install VS2017 SDKs), except for "pip install ffcv". Both versions are tested and yields:

(ffcv) C:\Users\Nico Stuurman>pip install ffcv
Collecting ffcv
  Using cached ffcv-0.0.2.tar.gz (53 kB)
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\miniconda3\envs\ffcv\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Nico Stuurman\\AppData\\Local\\Temp\\pip-install-6g53gzac\\ffcv_bec63284499b4f4eaef3c59145fdfa37\\setup.py'"'"'; __file__='"'"'C:\\Users\\Nico Stuurman\\AppData\\Local\\Temp\\pip-install-6g53gzac\\ffcv_bec63284499b4f4eaef3c59145fdfa37\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Nico Stuurman\AppData\Local\Temp\pip-pip-egg-info-2f42xkgr'
       cwd: C:\Users\Nico Stuurman\AppData\Local\Temp\pip-install-6g53gzac\ffcv_bec63284499b4f4eaef3c59145fdfa37\
  Complete output (7 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Nico Stuurman\AppData\Local\Temp\pip-install-6g53gzac\ffcv_bec63284499b4f4eaef3c59145fdfa37\setup.py", line 30, in <module>
      extension_kwargs = pkgconfig('opencv4', extension_kwargs)
    File "C:\Users\Nico Stuurman\AppData\Local\Temp\pip-install-6g53gzac\ffcv_bec63284499b4f4eaef3c59145fdfa37\setup.py", line 18, in pkgconfig
      raise Exception()
  Exception

Not sure where the logs are, but surely would expect 'pkgconfig' to be absent on Windows.

Any ideas?

@GuillaumeLeclerc
Copy link
Collaborator

Hello,

Unfortunately none of us own a windows machine so it will be hard for us to help troubleshoot this. We did not intend to support Windows in the first place.

We use pkg-config to find the paths to the libturbojpeg and opencv libraries. You could craft your own setup.py with the correct paths to these libraries.

Hope it helps :/

@kynk94
Copy link
Contributor

kynk94 commented Jan 21, 2022

I built ffcv successfully with my Windows 10 PC
This is the installation process I did.

Install opencv (https://opencv.org/releases/)
After install opencv, move to C:/opencv

Install libjpeg-turbo (https://sourceforge.net/projects/libjpeg-turbo/)
download libjpeg-turbo-x.x.x-vc64.exe, not gcc64

Install pthread (https://www.sourceware.org/pthreads-win32/)
I downloaded pthreads-w32-2-9-1-release.zip
After unzip, rename Pre-build.2 folder to pthread and move to C:/pthread

And install mingw.

We need to configure .pc file of above packages to find them with pkg-config.
pkg-config .pc files path: C:/msys64/mingw64/lib/pkgconfig

create and paste below files to pkg-config path

# opencv4.pc 

prefix=c:/opencv/build
exec_prefix=c:/opencv/build
libdir=c:/opencv/build/x64/vc15/lib
includedir=c:/opencv/build/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 4.5.5
Libs: -Lc:/opencv/build/x64/vc15/lib -lopencv_world455
Cflags: -Ic:/opencv/build/include
# libturbojpeg.pc

prefix=c:/libjpeg-turbo64
exec_prefix=c:/libjpeg-turbo64
libdir=c:/libjpeg-turbo64/lib
includedir=c:/libjpeg-turbo64/include

Name: libturbojpeg
Description: A SIMD-accelerated JPEG codec that provides the TurboJPEG API
Version: 2.1.2
Libs: -Lc:/libjpeg-turbo64/lib -lturbojpeg
Cflags: -Ic:/libjpeg-turbo64/include
# pthread.pc

Name: Pthread
Description: Pthread
Version: VC2
Libs: -LC:/pthread/lib/x64 -lpthreadVC2
Cflags: -IC:/pthread/include

Now pkg-config can recognize opencv4, libturbojpeg, pthread.

In setup.py, add extension_kwargs = pkgconfig('pthread', extension_kwargs)
and mute extension_kwargs['libraries'].extend(['pthread']), like below.

# setup.py
...
extension_kwargs = pkgconfig('opencv4', extension_kwargs)
extension_kwargs = pkgconfig('libturbojpeg', extension_kwargs)
extension_kwargs = pkgconfig('pthread', extension_kwargs)  # add this line.

# extension_kwargs['libraries'].extend(['pthread'])  # mute this line.
...

In libffcv/libffcv.cpp remove dunder from dunder uint in imdecode

// libffcv/libffcv.cpp
    int imdecode(unsigned char *input_buffer, uint64_t input_size,
                 uint32_t source_height, uint32_t source_width,
                 unsigned char *output_buffer,
                 uint32_t crop_height, uint32_t crop_width,
                 uint32_t offset_x, uint32_t offset_y,
                 uint32_t scale_num, uint32_t scale_denom,
                 bool enable_crop,
                 bool hflip)

Finally, can build ffcv by following command without error.

python setup.py bdist_wheel

However, I haven't checked the operation of ffcv on my Windows PC yet.

@GuillaumeLeclerc
Copy link
Collaborator

That's amazing. Feel tree to make a pull request if you are fine making this available to other users. In the meantime I will close this issue.

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

Successfully merging a pull request may close this issue.

3 participants