mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
* Revert "Fix wrong argument name (#5366)"
This reverts commit cc9d3b265d.
* Fix wrong argument naming
* Revert "Wrap torch::cuda::lazy_init with WITH_CUDA flag"
This reverts commit a8fa37f8fac5aef09eb7fe54d84de6126618c262.
* Revert "Solves the linking error related to lazy_init for MSVC"
This reverts commit 63913a102f274865a76e7c40ffdf6b40c277d5ff.
* better solution for the linking error related to lazy_init for MSVC
* Naming changes
* Namespace changes and further comment
* Rebasing onto current master
* Remove code that is useless
* Fix linting
* Remove rebasing bugs
24 lines
504 B
C++
24 lines
504 B
C++
#include "cuda_lazy_init.h"
|
|
|
|
#include <Python.h>
|
|
#include <mutex>
|
|
|
|
#include "torch/csrc/Exceptions.h"
|
|
#include "torch/csrc/utils/object_ptr.h"
|
|
|
|
namespace torch {
|
|
namespace utils {
|
|
|
|
void cuda_lazy_init() {
|
|
static std::once_flag once;
|
|
std::call_once(once, []() {
|
|
auto module = THPObjectPtr(PyImport_ImportModule("torch.cuda"));
|
|
if (!module) throw python_error();
|
|
auto res = THPObjectPtr(PyObject_CallMethod(module.get(), "_lazy_init", ""));
|
|
if (!res) throw python_error();
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|