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

Cython problem #160

Closed
raretomato opened this issue Apr 25, 2019 · 14 comments
Closed

Cython problem #160

raretomato opened this issue Apr 25, 2019 · 14 comments

Comments

@raretomato
Copy link

I installed TorchReID on another computer (win10, anaconda3) today with a new installation method (option 2) using conda.

After that, the message "rank.py:17: UserWarning: Cython evaluation (very fast) in unavailable, now use python evaluation" keeps appearing. I erased Cython and reinstalled it with the latest version, but it is still intact.

My Cython version is 0.29.7. Is not it compatible with the latest version of Cython?

@KaiyangZhou
Copy link
Owner

0.29.7 is the right version. If you go to deep-person-reid/torchreid/metrics/rank_cylib and run python test_cython.py, what do you get?

@KaiyangZhou
Copy link
Owner

How about trying re-install cython and then torchreid?

@raretomato
Copy link
Author

0.29.7 is the right version. If you go to deep-person-reid/torchreid/metrics/rank_cylib and run python test_cython.py, what do you get?

(torchreid) C:\Users\khanax\Documents\deep-person-reid-master\torchreid\metrics\rank_cylib>python test_cython.py
*** Compare running time ***
=> Using market1501's metric
Traceback (most recent call last):
File "test_cython.py", line 41, in
cytime = timeit.timeit('metrics.evaluate_rank(distmat, q_pids, g_pids, q_camids, g_camids, max_rank, use_cython=True)', setup=setup, number=20)
File "C:\Program Files\Anaconda3\envs\torchreid\lib\timeit.py", line 232, in timeit
return Timer(stmt, setup, timer, globals).timeit(number)
File "C:\Program Files\Anaconda3\envs\torchreid\lib\timeit.py", line 176, in timeit
timing = self.inner(it, self.timer)
File "", line 20, in inner
File "C:\Users\khanax\Documents\deep-person-reid-master\torchreid\metrics\rank_cylib/../../..\torchreid\metrics\rank.py", line 182, in evaluate_rank
return evaluate_cy(distmat, q_pids, g_pids, q_camids, g_camids, max_rank, use_metric_cuhk03)
File "torchreid\metrics\rank_cylib\rank_cy.pyx", line 24, in torchreid.metrics.rank_cylib.rank_cy.evaluate_cy
cpdef evaluate_cy(distmat, q_pids, g_pids, q_camids, g_camids, max_rank, use_metric_cuhk03=False):
File "torchreid\metrics\rank_cylib\rank_cy.pyx", line 32, in torchreid.metrics.rank_cylib.rank_cy.evaluate_cy
return eval_market1501_cy(distmat, q_pids, g_pids, q_camids, g_camids, max_rank)
ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'

@raretomato
Copy link
Author

How about trying re-install cython and then torchreid?

After re-install cython and torchreid, the warning message disappears.
But ValueError has happened.

@KaiyangZhou
Copy link
Owner

It seems to be related to the windows system. I searched several related discussions (e.g. this one) and could not find a solution for this. As I do not have windows system machine so cannot reproduce your error, sorry about that.

@shanqq377
Copy link

How about trying re-install cython and then torchreid?

After re-install cython and torchreid, the warning message disappears.
But ValueError has happened.

I have same problem. Have you find a soluton?

@KaiyangZhou
Copy link
Owner

@raretomato any updates on this issue?

@raretomato
Copy link
Author

@raretomato any updates on this issue?

I checked two points.

  1. I'm not sure whether it's reason of problem or not. In linux, I used sudo option for using "python setup.py develop". However, in Windows 10 (anaconda), I can't use that option. Then, even if I tried in "cmd on Administrator mode", I could not over-write "rank_cy.cp37-win_amd64.pyd" file in "torchreid/metrics/rank_cylib" folder by a permission issue. So I manually erase the file and do "python setup.py develop".

  2. About "ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'", I googled some answers. The main problem is "an np.int64 is a 'long' for linux and a 'long long' for windows.".
    So I changed every long type to long long type for 'rank_cy.pyx' file in the same folder above. Then it works.

@KaiyangZhou
Copy link
Owner

@raretomato Thanks.

@KaiyangZhou KaiyangZhou mentioned this issue Jul 31, 2019
@xinjiempolde
Copy link

@raretomato any updates on this issue?

I checked two points.

  1. I'm not sure whether it's reason of problem or not. In linux, I used sudo option for using "python setup.py develop". However, in Windows 10 (anaconda), I can't use that option. Then, even if I tried in "cmd on Administrator mode", I could not over-write "rank_cy.cp37-win_amd64.pyd" file in "torchreid/metrics/rank_cylib" folder by a permission issue. So I manually erase the file and do "python setup.py develop".
  2. About "ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'", I googled some answers. The main problem is "an np.int64 is a 'long' for linux and a 'long long' for windows.".
    So I changed every long type to long long type for 'rank_cy.pyx' file in the same folder above. Then it works.

Could you please provide more details? I got the same error at point 2, and I changed long type to long long type in the 'rank_cy.pyx' file. However, after doing this, it still doesn't work.

@busdac
Copy link

busdac commented Mar 30, 2020

@raretomato any updates on this issue?

I checked two points.

  1. I'm not sure whether it's reason of problem or not. In linux, I used sudo option for using "python setup.py develop". However, in Windows 10 (anaconda), I can't use that option. Then, even if I tried in "cmd on Administrator mode", I could not over-write "rank_cy.cp37-win_amd64.pyd" file in "torchreid/metrics/rank_cylib" folder by a permission issue. So I manually erase the file and do "python setup.py develop".
  2. About "ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'", I googled some answers. The main problem is "an np.int64 is a 'long' for linux and a 'long long' for windows.".
    So I changed every long type to long long type for 'rank_cy.pyx' file in the same folder above. Then it works.

Could you please provide more details? I got the same error at point 2, and I changed long type to long long type in the 'rank_cy.pyx' file. However, after doing this, it still doesn't work.

I have met exactly the same problem here about "long long" and "long". Here is my solution in 3 steps:

  1. change every "long" to "long long" in the file '/metrics/rank_cylib/rank_cy.pyx', just as @raretomato did.
  2. delete the file 'rank_cy.cp37-win_amd64.pyd' in the same folder manually.
  3. in terminal, re-run the command 'python setup.py develop'. Then you will see a new file ''rank_cy.cp37-win_amd64.pyd' generated under folder '/metrics/rank_cylib'

I have anaconda, phyton 3.7.7 under win10.
Beside the error mentioned above, I have to change the code to like (to avoid a socalled BrokenPipeError):

import torchreid
datamanager = torchreid.data.ImageDataManager(
..............................
..............................
engine = torchreid.engine.ImageSoftmaxEngine(
...............................
)
def main():
engine.run(
save_dir='E:/DL/deep-person-reid/log/resnet50',max_epoch=60, eval_freq=10, print_freq=10,test_only=False)

if name == "main":
main()

Now I have just succuessfully finished the training on 'cuhk01' and got the file '/log/resnet50\model.pth.tar-60'

@Bushra178
Copy link

@raretomato any updates on this issue?

I checked two points.

  1. I'm not sure whether it's reason of problem or not. In linux, I used sudo option for using "python setup.py develop". However, in Windows 10 (anaconda), I can't use that option. Then, even if I tried in "cmd on Administrator mode", I could not over-write "rank_cy.cp37-win_amd64.pyd" file in "torchreid/metrics/rank_cylib" folder by a permission issue. So I manually erase the file and do "python setup.py develop".
  2. About "ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'", I googled some answers. The main problem is "an np.int64 is a 'long' for linux and a 'long long' for windows.".
    So I changed every long type to long long type for 'rank_cy.pyx' file in the same folder above. Then it works.

I tried manually deleting rank_cy file. it still gives the same error on windows.

@alexbarnadas
Copy link

Any update on that Issue? I have the same problem on ubuntu and windows machines

@AnkitBilla11
Copy link

Facing the same issue while installing on an M2 MacOS environment. Any further updates?

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

8 participants