facebookresearch / diffq

DiffQ performs differentiable quantization using pseudo quantization noise. It can automatically tune the number of bits used per weight or group of weights, in order to achieve a given trade-off between model size and accuracy.
Other
234 stars 15 forks source link

Getting error by pip install diffq on Windows #12

Closed PETERCHUU closed 1 year ago

PETERCHUU commented 1 year ago

πŸ› Bug Report

I'm trying to install the diffp on windows, I try the powershell,cmd on administrator mode, but didn't work, it output same error for my .

I find out there are specific cmd that not work

"F:\C#\Microsoft Visual Studio\VC\Tools\MSVC\14.35.32215\bin\HostX86\x64\cl.exe" /E /C /nologo /O2 /W3 /GL /DNDEBUG /MD -Ic:\Users\chow\Desktop\programme\python\project\.venv\include -IC:\Users\chow\AppData\Local\Programs\Python\Python311\include -IC:\Users\chow\AppData\Local\Programs\Python\Python311\Include "-IF:\C#\Microsoft Visual Studio\VC\Tools\MSVC\14.35.32215\include" "-IF:\C#\Microsoft Visual Studio\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tcbitpack.c /Fobuild\temp.win-amd64-cpython-311\Release\bitpack.obj this command output are error

error: c1 fatal error c1083 cannot open source file: 'bitpack.c': no such file or directory

I try a different cl.exe that store in .\Hostx64\x64, add /E to ci cmmand, still not work.

So I think there something wrong about VS , so I install the python toolkit in vs installer, and yet still not work

ozelentok commented 1 year ago

setup.py is missing the call to cythonize

diff --git a/setup.py b/setup.py
index c81e002..8cf20b7 100644
--- a/setup.py
+++ b/setup.py
@@ -8,6 +8,7 @@

 from pathlib import Path
 from setuptools import setup, Extension
+from Cython.Build import cythonize

 NAME = 'diffq'
 DESCRIPTION = ('Differentiable quantization framework for PyTorch.')
@@ -43,9 +44,9 @@ setup(
     url=URL,
     packages=['diffq'],
     install_requires=['Cython', 'numpy', 'torch'],
-    ext_modules=[Extension(
+    ext_modules=cythonize([Extension(
         "diffq.bitpack",
-        sources=["bitpack.pyx"])],
+        sources=["bitpack.pyx"])]),
     extras_require={'dev': ['coverage', 'flake8', 'pdoc3', 'torchvision']},
     include_package_data=True,
     license='Creative Commons Attribution-NonCommercial 4.0 International',
PETERCHUU commented 1 year ago

it's work!!, thank you o much

adefossez commented 1 year ago

@ozelentok thanks for the fix I updated the file.