未验证 提交 33765c34 编写于 作者: J Juncheng 提交者: GitHub

Only query PCI bus id when CUDA version >= 11 (#5937)

Co-authored-by: Noneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
上级 9bedea27
......@@ -19,6 +19,7 @@ limitations under the License.
#ifdef WITH_CUDA
#include <cuda_runtime.h>
#include <cuda.h>
#include <json.hpp>
namespace oneflow {
......@@ -92,7 +93,8 @@ std::shared_ptr<const CudaDeviceDescriptor> CudaDeviceDescriptor::Query(int32_t
desc->impl_->memory_clock_rate_khz = prop.memoryClockRate;
desc->impl_->memory_bus_width_bit = prop.memoryBusWidth;
char pci_bus_id_buf[sizeof("00000000:00:00.0")];
if (cudaDeviceGetPCIBusId(pci_bus_id_buf, sizeof(pci_bus_id_buf), ordinal) == cudaSuccess) {
if (CUDA_VERSION >= 11000
&& cudaDeviceGetPCIBusId(pci_bus_id_buf, sizeof(pci_bus_id_buf), ordinal) == cudaSuccess) {
for (int i = 0; i < sizeof(pci_bus_id_buf) - 1; ++i) {
pci_bus_id_buf[i] = static_cast<char>(std::tolower(pci_bus_id_buf[i]));
}
......
......@@ -125,6 +125,7 @@ class HWLocTopologyDescriptor : public TopologyDescriptor {
std::shared_ptr<const TopologyCPUAffinityDescriptor> GetCPUAffinityByPCIBusID(
const std::string& bus_id) const override {
if (bus_id.empty()) { return nullptr; }
hwloc_obj_t non_io_ancestor = GetNonIOAncestorByPCIBusID(bus_id);
if (non_io_ancestor == nullptr) { return nullptr; }
if (non_io_ancestor->cpuset == nullptr) { return nullptr; }
......@@ -134,6 +135,7 @@ class HWLocTopologyDescriptor : public TopologyDescriptor {
std::shared_ptr<const TopologyMemoryAffinityDescriptor> GetMemoryAffinityByPCIBusID(
const std::string& bus_id) const override {
if (bus_id.empty()) { return nullptr; }
hwloc_obj_t non_io_ancestor = GetNonIOAncestorByPCIBusID(bus_id);
if (non_io_ancestor == nullptr) { return nullptr; }
if (non_io_ancestor->nodeset == nullptr) { return nullptr; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册