-
Notifications
You must be signed in to change notification settings - Fork 66
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
Error during YOLOv8s quantization with Ryzen AI quantizer (RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn) #122
Comments
Hi @Siva50005, The quantization of Yolov8 needs QAT process to maintain the accuracy which is excluded from the tutorial. In my humble opinion, the issue could result from the virtual env like WSL. Do you have a real Linux env to run the quantizer? We have provided the docker image below to simplify the installation process for a quick validation. |
Thank you for your prompt response. I agree that the QAT process can be computationally expensive, especially when maintaining accuracy. However, the runtime error I encountered was unexpected, and I appreciate your point regarding the use of virtual environments like WSL potentially being a factor. I used the docker image which was provided in the pytorch quantization tutorial. Currently, I am running the quantizer within a WSL environment on my system, and it’s possible that this could be contributing to the issue. I will try running the provided docker image directly on windows/linux environment. I’ll reach out if I run into any further issues. Thank you. |
I have been stuck at quantizing this yolov8 model for the past couple of days. If possible can you provide me some concrete steps to quantize it without QAT which is really time consuming? Possibly a PTQ would do Thanks in advance Best regards |
Hi @Siva50005, I hope the script below could help. |
Have tried this on the docker which was installed in the AMD ryzen machine. But i got some dependency issues which i was able to resolve but when i ran this command:
Can you help me resolve this issue? This is urgent |
You may try to install the dependency below. |
I had installed them already before i ran the
When I saw the packages installed using pip list, i couldnt find the ultralytics library. |
Also I have a doubt that, In the readme file here: https://github.com/amd/RyzenAI-SW/tree/1.1/tutorial/yolov8_e2e It says that the supported CPUs are AMD Ryzen 7040U, 7040HS series mobile processors But I am trying to do this on AMD Ryzen 9 7940HS. It wont be a problem right? |
That's the Readme for previous release(v1.1). The quantization flow is removed from the latest release due to GPL license issue. But in the latest release, if you managed to inference a FP32 Yolov8 model on CPU, the ptq script should work within the provided docker image. |
I'm already trying to run the ptq script inside the docker image. But it still isn't working. |
If you still face the same issue stated above, please refer to the link below to verify a float point yolov8 model first before get to the quantization stage. |
I encountered an issue while trying to quantize the YOLOv8s model using the Ryzen AI quantizer. Below are the details of the error:
Error Message:
Environment:
Steps to Reproduce:
new_quant.py:
Additional Information:
Expected Behavior:
The quantization process should complete successfully without raising a
RuntimeError
.The text was updated successfully, but these errors were encountered: