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

Setup.py Failed toolkit/utils/region.pyx:11:8: 'c_region.pxd' not found #172

Open
andreeaboiciuc opened this issue Nov 25, 2024 · 2 comments

Comments

@andreeaboiciuc
Copy link

andreeaboiciuc commented Nov 25, 2024

Issue: Compiling NanoTracker Setup

Description

Hello there! I'm trying to use the train for NanoTracker. I have installed all the necessary packages from the requirements with default versions for Python 3.12. I am running Ubuntu 24.04. Below is the list of installed package versions:

Package Version
torch 2.5.1+cu121
torchvision 0.20.1+cu121
torchaudio 2.5.1+cu121
matplotlib 3.9.2
pandas 2.2.3
opencv-python 4.10.0.84
tensorboardX 2.6.2.2
Cython 3.0.11
yacs 0.1.8
scikit-image 0.24.0
pillow 11.0.0
scipy 1.14.1
shapely 2.0.6
tqdm 4.67.1
easydict 1.13
jpeg4py 0.1.4
mpi4py 4.0.1
ray 2.39.0
hyperopt 0.2.7

Steps to Reproduce

  1. Clone the NanoTracker repository.
  2. Install dependencies using the requirements file.
  3. Run the following command to build:
    python setup.py build_ext --inplace
    
    
    

After I want to make the build :

but i have this issue:

python setup.py build_ext --inplace
Compiling toolkit/utils/region.pyx because it changed.
[1/1] Cythonizing toolkit/utils/region.pyx

Error compiling Cython file:

...

from libc.stdlib cimport malloc, free
from libc.stdio cimport sprintf
from libc.string cimport strlen

cimport c_region
^

toolkit/utils/region.pyx:11:8: 'c_region.pxd' not found

Error compiling Cython file:

...
RECTANGEL
POLYGON
MASK

cdef class RegionBounds:
cdef c_region.region_bounds* _c_region_bounds
^

toolkit/utils/region.pyx:21:9: 'region_bounds' is not a type identifier

Error compiling Cython file:

...
self._c_region_bounds.bottom = bottom
self._c_region_bounds.left = left
self._c_region_bounds.right = right

cdef class Rectangle:
cdef c_region.region_rectangle* _c_region_rectangle
^

toolkit/utils/region.pyx:58:9: 'region_rectangle' is not a type identifier

Error compiling Cython file:

...
self._c_region_rectangle.y,
self._c_region_rectangle.width,
self._c_region_rectangle.height)

cdef class Polygon:
cdef c_region.region_polygon* _c_region_polygon
^

toolkit/utils/region.pyx:99:9: 'region_polygon' is not a type identifier

Error compiling Cython file:

...
else:
pno_bounds = RegionBounds(-float("inf"), float("inf"),
-float("inf"), float("inf"))
cdef float only1 = 0
cdef float only2 = 0
cdef c_region.region_polygon* c_polygon1 = polygon1_._c_region_polygon
^

toolkit/utils/region.pyx:182:9: 'region_polygon' is not a type identifier

Error compiling Cython file:

...
pno_bounds = RegionBounds(-float("inf"), float("inf"),
-float("inf"), float("inf"))
cdef float only1 = 0
cdef float only2 = 0
cdef c_region.region_polygon* c_polygon1 = polygon1_.c_region_polygon
cdef c_region.region_polygon* c_polygon2 = polygon2
._c_region_polygon
^

toolkit/utils/region.pyx:183:9: 'region_polygon' is not a type identifier

Error compiling Cython file:

...
-float("inf"), float("inf"))
cdef float only1 = 0
cdef float only2 = 0
cdef c_region.region_polygon* c_polygon1 = polygon1_.c_region_polygon
cdef c_region.region_polygon* c_polygon2 = polygon2
._c_region_polygon
cdef c_region.region_bounds no_bounds = pno_bounds._c_region_bounds[0] # deference
^

toolkit/utils/region.pyx:184:9: 'region_bounds' is not a type identifier

Error compiling Cython file:

...

cdef class RegionBounds:
cdef c_region.region_bounds* _c_region_bounds

def cinit(self):
self._c_region_bounds = <c_region.region_bounds*>malloc(
^

toolkit/utils/region.pyx:24:33: 'region_bounds' is not a type identifier

Error compiling Cython file:

...
cdef class RegionBounds:
cdef c_region.region_bounds* _c_region_bounds

def cinit(self):
self._c_region_bounds = <c_region.region_bounds*>malloc(
sizeof(c_region.region_bounds))
^

toolkit/utils/region.pyx:25:32: cimported module has no attribute 'region_bounds'

Error compiling Cython file:

...

cdef class Rectangle:
cdef c_region.region_rectangle* _c_region_rectangle

def cinit(self):
self._c_region_rectangle = <c_region.region_rectangle*>malloc(
^

toolkit/utils/region.pyx:61:36: 'region_rectangle' is not a type identifier

Error compiling Cython file:

...
cdef class Rectangle:
cdef c_region.region_rectangle* _c_region_rectangle

def cinit(self):
self._c_region_rectangle = <c_region.region_rectangle*>malloc(
sizeof(c_region.region_rectangle))
^

toolkit/utils/region.pyx:62:32: cimported module has no attribute 'region_rectangle'

Error compiling Cython file:

...
args:
points: tuple of point
points = ((1, 1), (10, 10))
"""
num = len(points) // 2
self._c_region_polygon = <c_region.region_polygon*>malloc(
^

toolkit/utils/region.pyx:108:34: 'region_polygon' is not a type identifier

Error compiling Cython file:

...
points: tuple of point
points = ((1, 1), (10, 10))
"""
num = len(points) // 2
self._c_region_polygon = <c_region.region_polygon*>malloc(
sizeof(c_region.region_polygon))
^

toolkit/utils/region.pyx:109:32: cimported module has no attribute 'region_polygon'

Error compiling Cython file:

...
sizeof(c_region.region_polygon))
if not self._c_region_polygon:
self._c_region_polygon = NULL
raise MemoryError()
self._c_region_polygon.count = num
self._c_region_polygon.x = <float*>malloc(sizeof(float) * num)
^

toolkit/utils/region.pyx:114:35: Cannot convert 'float *' to Python object

Error compiling Cython file:

...
raise MemoryError()
self._c_region_polygon.count = num
self._c_region_polygon.x = <float*>malloc(sizeof(float) * num)
if not self._c_region_polygon.x:
raise MemoryError()
self._c_region_polygon.y = <float*>malloc(sizeof(float) * num)
^

toolkit/utils/region.pyx:117:35: Cannot convert 'float *' to Python object

Error compiling Cython file:

...
self._c_region_polygon.x[i] = points[i2]
self._c_region_polygon.y[i] = points[i
2+1]

def dealloc(self):
if self._c_region_polygon is not NULL:
if self._c_region_polygon.x is not NULL:
^

toolkit/utils/region.pyx:127:40: Invalid types for 'is_not' (Python object, void *)

Error compiling Cython file:

...
self._c_region_polygon.y[i] = points[i*2+1]

def dealloc(self):
if self._c_region_polygon is not NULL:
if self._c_region_polygon.x is not NULL:
free(self._c_region_polygon.x)
^

toolkit/utils/region.pyx:128:43: Cannot convert Python object to 'void *'

Error compiling Cython file:

...

def dealloc(self):
if self._c_region_polygon is not NULL:
if self._c_region_polygon.x is not NULL:
free(self._c_region_polygon.x)
self._c_region_polygon.x = NULL
^

toolkit/utils/region.pyx:129:43: Cannot convert 'void *' to Python object

Error compiling Cython file:

...
def dealloc(self):
if self._c_region_polygon is not NULL:
if self._c_region_polygon.x is not NULL:
free(self._c_region_polygon.x)
self._c_region_polygon.x = NULL
if self._c_region_polygon.y is not NULL:
^

toolkit/utils/region.pyx:130:40: Invalid types for 'is_not' (Python object, void *)

Error compiling Cython file:

...
if self._c_region_polygon is not NULL:
if self._c_region_polygon.x is not NULL:
free(self._c_region_polygon.x)
self._c_region_polygon.x = NULL
if self._c_region_polygon.y is not NULL:
free(self._c_region_polygon.y)
^

toolkit/utils/region.pyx:131:43: Cannot convert Python object to 'void *'

Error compiling Cython file:

...
if self._c_region_polygon.x is not NULL:
free(self._c_region_polygon.x)
self._c_region_polygon.x = NULL
if self._c_region_polygon.y is not NULL:
free(self._c_region_polygon.y)
self._c_region_polygon.y = NULL
^

toolkit/utils/region.pyx:132:43: Cannot convert 'void *' to Python object

Error compiling Cython file:

...
cdef float only1 = 0
cdef float only2 = 0
cdef c_region.region_polygon* c_polygon1 = polygon1_.c_region_polygon
cdef c_region.region_polygon* c_polygon2 = polygon2
._c_region_polygon
cdef c_region.region_bounds no_bounds = pno_bounds._c_region_bounds[0] # deference
return c_region.compute_polygon_overlap(c_polygon1,
^

toolkit/utils/region.pyx:185:19: cimported module has no attribute 'compute_polygon_overlap'

Traceback (most recent call last):
File "/home/andreea/Documents/SiamTrackers/NanoTrack/setup.py", line 22, in
ext_modules=cythonize(
^^^^^^^^^^
File "/home/andreea/tracker/lib/python3.12/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
cythonize_one(*args)
File "/home/andreea/tracker/lib/python3.12/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: toolkit/utils/region.pyx

mention that the files are present in the belonging folder/folders. toolkit/utils/ and toolkit/utils/src .So i don't get why the issue persists. Can you please indicate what the issue could be to be able to make the train? Thanks a lot in advance .

@733ly
Copy link

733ly commented Dec 16, 2024

I have the same problem!!

@XY-ZXY
Copy link

XY-ZXY commented Jan 2, 2025

可以试一试将Cython的版本退回0.29.21

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

No branches or pull requests

3 participants