Hi, I encountered an importing error when I am running the code in the Convert your model to integral models of the Readme file.
import torch
import torch_integral as inn
from torchvision.models import resnet18
model = resnet18(pretrained=True)
wrapper = inn.IntegralWrapper(init_from_discrete=True)
# Specify continuous dimensions which you want to prune
continuous_dims = {
"layer4.0.conv1.weight": [0],
"layer4.1.conv1.weight": [0, 1]
}
# Convert to integral model
inn_model = wrapper(model, (1, 3, 224, 224), continuous_dims)
ssh://gyli@10.135.78.31:22/home/gyli/anaconda3/envs/inn/bin/python -u /home/gyli/dreams/TorchIntegral/test.py
/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/gyli/dreams/TorchIntegral/torch_integral/tsp_solver/solver.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
/home/gyli/.pyxbld/temp.linux-x86_64-cpython-310/pyrex/torch_integral/tsp_solver/solver.c:752:10: fatal error: numpy/arrayobject.h: No such file or directory
#include "numpy/arrayobject.h"
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Traceback (most recent call last):
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/unixccompiler.py", line 185, in _compile
self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/ccompiler.py", line 1041, in spawn
spawn(cmd, dry_run=self.dry_run, **kwargs)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/usr/bin/gcc' failed with exit code 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/pyximport/pyximport.py", line 214, in load_module
so_path = build_module(module_name, pyxfilename, pyxbuild_dir,
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/pyximport/pyximport.py", line 186, in build_module
so_path = pyxbuild.pyx_to_dll(pyxfilename, extension_mod,
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/pyximport/pyxbuild.py", line 102, in pyx_to_dll
dist.run_commands()
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
self.run_command(cmd)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/dist.py", line 1244, in run_command
super().run_command(command)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
self.build_extensions()
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
_build_ext.build_ext.build_extensions(self)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions
self._build_extensions_serial()
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial
self.build_extension(ext)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 548, in build_extension
objects = self.compiler.compile(
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/ccompiler.py", line 600, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/unixccompiler.py", line 187, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command '/usr/bin/gcc' failed with exit code 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/gyli/dreams/TorchIntegral/test.py", line 4, in <module>
import torch_integral as inn
File "/home/gyli/dreams/TorchIntegral/torch_integral/__init__.py", line 1, in <module>
from .model import IntegralWrapper
File "/home/gyli/dreams/TorchIntegral/torch_integral/model.py", line 11, in <module>
from .permutation import NOptPermutation
File "/home/gyli/dreams/TorchIntegral/torch_integral/permutation.py", line 2, in <module>
from .tsp_solver import two_opt_find_permutation
File "/home/gyli/dreams/TorchIntegral/torch_integral/tsp_solver/__init__.py", line 1, in <module>
from .solver import two_opt_find_permutation
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/pyximport/pyximport.py", line 459, in load_module
module = load_module(fullname, self.path,
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/pyximport/pyximport.py", line 231, in load_module
raise exc.with_traceback(tb)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/pyximport/pyximport.py", line 214, in load_module
so_path = build_module(module_name, pyxfilename, pyxbuild_dir,
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/pyximport/pyximport.py", line 186, in build_module
so_path = pyxbuild.pyx_to_dll(pyxfilename, extension_mod,
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/pyximport/pyxbuild.py", line 102, in pyx_to_dll
dist.run_commands()
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
self.run_command(cmd)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/dist.py", line 1244, in run_command
super().run_command(command)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
self.build_extensions()
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
_build_ext.build_ext.build_extensions(self)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions
self._build_extensions_serial()
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial
self.build_extension(ext)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 548, in build_extension
objects = self.compiler.compile(
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/ccompiler.py", line 600, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/gyli/anaconda3/envs/inn/lib/python3.10/site-packages/setuptools/_distutils/unixccompiler.py", line 187, in _compile
raise CompileError(msg)
ImportError: Building module torch_integral.tsp_solver.solver failed: ["distutils.errors.CompileError: command '/usr/bin/gcc' failed with exit code 1\n"]
It seems that I cannot compile the Cython code with my gcc compiler. Do you have any ideas to resolve this issue? Many thanks.
Hi, I encountered an importing error when I am running the code in the Convert your model to integral models of the Readme file.
My environment is:
I failed with the error:
It seems that I cannot compile the Cython code with my gcc compiler. Do you have any ideas to resolve this issue? Many thanks.