-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
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
How to close the amp? #12903
Comments
👋 Hello @Git376364743, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it. If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results. RequirementsPython>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. To get started: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit. Introducing YOLOv8 🚀We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀! Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects. Check out our YOLOv8 Docs for details and get started with: pip install ultralytics |
Hello! 😊 It seems like you're facing a dtype mismatch issue when integrating a custom module into YOLOv5, and you're interested in turning off Automatic Mixed Precision (AMP) as a potential solution. For disabling AMP in your training, you can adjust the python train.py --img 640 --batch 16 --epochs 3 --data dataset.yaml --weights yolov5s.pt --amp False This command assumes you're training with the default settings but with AMP explicitly turned off. Keep in mind, disabling AMP might increase memory usage and potentially decrease training speed, so monitor performance closely. Remember, modifications like adding custom modules might require additional adjustments, especially regarding tensor types, to ensure compatibility throughout your model. If further issues arise, or if you have additional questions, feel free to reach out! Happy coding! |
@glenn-jocher Thanks for your reply, but I found that yolov5-master doesn't have the amp function, and I get an error in the train command with --amp False: "train.py: error: unrecognized arguments: --amp False", please give me another solution! |
Hello! 😊 It looks like there was some confusion regarding the One way to work around precision mismatches without a specific AMP toggle is to ensure all your custom module's tensors and weights are set to the appropriate dtype (e.g., If you're facing a specific error due to tensor type mismatches, a code adjustment like the following within your custom module might help: class MyCustomModule(nn.Module):
def __init__(self):
super(MyCustomModule, self).__init__()
# Your initialization code
def forward(self, x):
x = x.float() # Ensure input is FloatTensor
# Your forward pass code
return x Double-check to ensure all inputs and operations inside your custom module are compatible with floating-point operations. If problems persist, please share more specifics about the mismatch or error for further assistance. Happy to help! |
@glenn-jocher Thank you for your answer, but I followed the method and still could not solve the problem "RuntimeError: input type (torch.cuda.HalfTensor) and weight type (torch.cuda.FloatTensor) should be same". Here is the code I referenced that I wanted to incorporate: class HWD(nn.Module):
Here is the structure of my yolov5s.yaml file: Parametersnc: 4 # number of classes
YOLOv5 v6.0 backbonebackbone: [from, number, module, args][ YOLOv5 v6.0 headhead: [
] Here's all the info, looking forward to your help |
Hello again! 😊 It looks like the core issue resides in the interaction between the custom To address the "RuntimeError: input type (torch.cuda.HalfTensor) and weight type (torch.cuda.FloatTensor) should be same", let's focus on ensuring consistent tensor types throughout the Since AMP can lead to inputs being in half precision, and your custom layer might not support half precision operations directly or might be expecting full precision inputs, you're seeing this inconsistency. However, One thing you could try is ensuring the output of If these suggestions don't resolve the issue, as a workaround, you might need to adjust the training script or the custom module slightly to avoid automatic mixed precision for this particular operation. This could involve a deeper modification to ensure compatibility with mixed precision training environments. Since your problem does seem quite intricate and possibly specific to the way mixed precision interacts with custom modules and external libraries, further investigation and potentially more detailed debugging might be required to pinpoint the exact cause and solution. Keep experimenting, and don't hesitate to share more details if you continue facing challenges! |
👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help. For additional resources and information, please see the links below:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed! Thank you for your contributions to YOLO 🚀 and Vision AI ⭐ |
请问您的这个问题解决了嘛? |
@love-whut hello! 😊 It looks like the issue persists with the tensor type mismatch in your custom
Here's a revised version of your def forward(self, x):
x = x.float() # Convert input to float
yL, yH = self.wt(x)
y_HL = yH[0][:, :, 0, :].float() # Ensure all components are float
y_LH = yH[0][:, :, 1, :].float()
y_HH = yH[0][:, :, 2, :].float()
x = torch.cat([yL, y_HL, y_LH, y_HH], dim=1)
x = self.conv(x)
return x
If these adjustments don't solve the problem, you might need to look deeper into how Keep experimenting, and let me know how it goes! |
👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help. For additional resources and information, please see the links below:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed! Thank you for your contributions to YOLO 🚀 and Vision AI ⭐ |
Search before asking
Question
I want to add HWD module in yolov5-7.0, the changed yolovs.yaml file can be run in yolo.py but not in train.py file, please help me to see what causes the error, thanks!
RuntimeError: Input type (torch.cuda.HalfTensor) and weight type (torch.cuda.FloatTensor) should be the same
In other forums some people answered that it can be run after turning off AMP, please tell me how to turn off AMP!
Additional
No response
The text was updated successfully, but these errors were encountered: