ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
Find a file
pengwa dfac096501
Fix segfault for multiple GPU run (regression) (#15823)
### Fix segfault for multiple GPU run

https://github.com/microsoft/onnxruntime/pull/15618 introduced
`GetOrtDeviceByMemType`. The intention should be: handle CPU device
differently in the if branch, while might by mistakenly passing the
unique default non-cpu device id.


```
OrtDevice CUDAExecutionProvider::GetOrtDeviceByMemType(OrtMemType mem_type) const {
  if (mem_type == OrtMemTypeCPUInput || mem_type == OrtMemTypeCPUOutput) {
    return OrtDevice(OrtDevice::CPU, OrtDevice::MemType::CUDA_PINNED, default_device_.Id());
  }
  return default_device_;
}
```

We observed a segement fault thrown when running multiple GPU training  

`
CUDA_LAUNCH_BLOCKING=1 python -m torch.distributed.launch
--nproc_per_node=2
examples/onnxruntime/training/language-modeling/run_mlm.py
--model_name_or_path distilbert-base-uncased --dataset_name wikitext
--dataset_config_name wikitext-2-raw-v1 --num_train_epochs 10
--per_device_train_batch_size 8 --per_device_eval_batch_size 8
--do_train --do_eval --overwrite_output_dir --output_dir ./outputs222/
--seed 1137 --fp16 --report_to none --optim adamw_ort_fused --max_steps
400 --logging_steps 1
`

It is found GPU0 works fine, GPU1 throw segement fault. Looking further,
a Shape node trying to allocate it's output tensor, trying to fetch
corresponding allocator with ORTDevice(Device:[DeviceType:0 MemoryType:1
DeviceId:1]), while CPU device did not have device id = 1, so a no
allocator returned. When we try to call `AsStreamBasedAllocator` for the
allocator, segement happens as no null check was done there.



### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
2023-05-06 08:48:53 +08:00
.config Update tsaoptions.json: update the email alias (#13448) 2022-10-26 15:56:16 -07:00
.devcontainer Remove two lines in the Dockerfile for Github Codespace (#12278) 2022-07-21 20:52:17 -07:00
.gdn Update compliance tasks in python packaging pipeline and fix some compile warnings (#8471) 2021-07-30 17:16:37 -07:00
.github Add a Github workflow for Prefast (#15763) 2023-05-03 11:42:51 -07:00
.pipelines Add a codesign step to Windows AI nuget pipeline (#15816) 2023-05-04 22:07:44 -07:00
.vscode cpplint & Eager mode: refactor and add comments to empty_* functions, general lint cleanup in ort_aten (#12238) 2022-07-20 11:47:57 -04:00
cgmanifests update ort extensions to 94142d8391c9791ec71c38336436319a2d4ac7a0 (#15688) 2023-05-05 09:48:07 -07:00
cmake update ort extensions to 94142d8391c9791ec71c38336436319a2d4ac7a0 (#15688) 2023-05-05 09:48:07 -07:00
csharp Various fixes to the CSharp setup (#15782) 2023-05-05 14:27:30 +10:00
dockerfiles Update cmake version in Linux build (#15707) 2023-04-27 20:02:33 -07:00
docs Add GridSample implementation to DirectML (#15788) 2023-05-05 15:59:33 -07:00
include/onnxruntime/core Implement lite custom op API (#15778) 2023-05-04 09:49:17 -07:00
java Creating Nuget and Android packages for Training (#15712) 2023-05-01 12:59:56 -07:00
js Bump engine.io from 6.4.1 to 6.4.2 in /js/web (#15799) 2023-05-04 10:06:01 -07:00
objectivec Add iOS Swift Package Manager support (#15297) 2023-04-20 16:18:35 +10:00
onnxruntime Fix segfault for multiple GPU run (regression) (#15823) 2023-05-06 08:48:53 +08:00
orttraining Update softmax_grad_impl.cu: add constexpr (#15794) 2023-05-04 08:10:17 -07:00
rust Add rust bindings (#12606) 2023-02-08 14:57:15 -08:00
samples Enable pylint and numpy rules (#15218) 2023-03-27 20:37:53 -07:00
swift/OnnxRuntimeBindingsTests Add iOS Swift Package Manager support (#15297) 2023-04-20 16:18:35 +10:00
tools [QNN EP] Update default QNN SDK to version 2.10.0 (#15818) 2023-05-05 13:01:21 -07:00
winml Add GridSample implementation to DirectML (#15788) 2023-05-05 15:59:33 -07:00
.clang-format Run clang-format in CI (#15524) 2023-04-18 09:26:58 -07:00
.clang-tidy Create clang-tidy CI (#12653) 2022-09-30 08:05:38 -07:00
.dockerignore Update dockerfiles (#5929) 2020-11-25 15:38:22 -08:00
.gitattributes
.gitignore remove 'lib/' from .gitignore (#15613) 2023-04-24 18:43:32 -07:00
.gitmodules Remove protobuf submodule (#15190) 2023-03-27 10:35:49 -07:00
.lintrunner.toml Enable RUFF as a formatter (#15699) 2023-04-26 14:04:07 -07:00
build.amd64.1411.bat
build.bat
build.sh Add iOS test pipeline and a sample app. (#5298) 2020-09-29 13:53:11 -07:00
CITATION.cff Fix CITATION.cff and add automatic validation of your citation metadata (#10478) 2022-04-13 10:03:52 -07:00
CODEOWNERS Add owners for public facing API files (#15288) 2023-03-30 17:16:15 -07:00
CONTRIBUTING.md Fix link to High Level Design (#11786) 2023-02-28 11:05:54 -08:00
lgtm.yml Fix lgtm C++ error (#13613) 2022-11-10 10:06:22 -08:00
LICENSE Remove year from license (#6658) 2021-02-12 00:25:56 -08:00
NuGet.config Delete nuget extra configs (#6477) 2021-01-27 20:25:45 -08:00
ort.wprp
ORT_icon_for_light_bg.png Update nuget icon (#10672) 2022-03-01 09:11:03 -08:00
Package.swift Add iOS Swift Package Manager support (#15297) 2023-04-20 16:18:35 +10:00
packages.config Download protoc.exe from nuget when cross-compiling (#15395) 2023-04-06 17:06:59 -07:00
pyproject.toml Bump ruff in CI (#15533) 2023-04-17 10:11:44 -07:00
README.md [Readme] Update table for build pipelines (#14618) 2023-02-08 09:44:20 -08:00
requirements-dev.txt Remove codecov from requirements-dev.txt (#15487) 2023-04-12 18:48:02 -07:00
requirements-doc.txt Add auto doc gen for ORTModule API during CI build (#7046) 2021-03-22 10:20:33 -07:00
requirements-lintrunner.txt Enable RUFF as a formatter (#15699) 2023-04-26 14:04:07 -07:00
requirements-training.txt Remove protobuf pin from training requirements (#13695) 2022-11-22 12:27:18 -08:00
requirements.txt.in Add additional python requirements (#11522) 2022-05-20 16:16:18 -07:00
SECURITY.md Microsoft mandatory file (#11619) 2022-05-25 13:56:10 -07:00
setup.py Fix bug when adding Whisper to wheel (#15708) 2023-04-28 16:03:55 -07:00
ThirdPartyNotices.txt [js/web] WebGPU backend via JSEP (#14579) 2023-04-24 15:21:18 -07:00
VERSION_NUMBER Update VERSION_NUMBER (#15773) 2023-05-03 15:07:34 -07:00

ONNX Runtime is a cross-platform inference and training machine-learning accelerator.

ONNX Runtime inference can enable faster customer experiences and lower costs, supporting models from deep learning frameworks such as PyTorch and TensorFlow/Keras as well as classical machine learning libraries such as scikit-learn, LightGBM, XGBoost, etc. ONNX Runtime is compatible with different hardware, drivers, and operating systems, and provides optimal performance by leveraging hardware accelerators where applicable alongside graph optimizations and transforms. Learn more →

ONNX Runtime training can accelerate the model training time on multi-node NVIDIA GPUs for transformer models with a one-line addition for existing PyTorch training scripts. Learn more →

Get Started & Resources

Build Pipeline Status

System Inference Training
Windows Build Status
Build Status
Build Status
Linux Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Mac Build Status
Android Build Status
iOS Build Status
Web Build Status
Other Build Status
Build Status

Data/Telemetry

Windows distributions of this project may collect usage data and send it to Microsoft to help improve our products and services. See the privacy statement for more details.

Contributions and Feedback

We welcome contributions! Please see the contribution guidelines.

For feature requests or bug reports, please file a GitHub Issue.

For general discussion or questions, please use GitHub Discussions.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

License

This project is licensed under the MIT License.