You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

libnvrtc.cpp 2.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * \file dnn/cuda-stub/src/libnvrtc.cpp
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
  6. *
  7. * Unless required by applicable law or agreed to in writing,
  8. * software distributed under the License is distributed on an
  9. * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. * implied.
  11. */
  12. #pragma GCC visibility push(default)
  13. #include <cstdio>
  14. #define LOGE(fmt, v...) fprintf(stderr, "err: " fmt "\n", ##v)
  15. #include "./nvrtc_type.h"
  16. #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  17. static void log_failed_load(int func_idx);
  18. namespace {
  19. template <typename T>
  20. T on_init_failed(int func_idx);
  21. template <>
  22. nvrtcResult on_init_failed(int func_idx) {
  23. log_failed_load(func_idx);
  24. return NVRTC_ERROR_INTERNAL_ERROR;
  25. }
  26. template <>
  27. const char* on_init_failed(int func_idx) {
  28. log_failed_load(func_idx);
  29. return "load lib failed";
  30. }
  31. } // namespace
  32. #include "./libnvrtc-wrap.h"
  33. static const char* default_so_name =
  34. #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
  35. "nvrtc.dll";
  36. #elif defined(__APPLE__) || defined(__MACOSX)
  37. "libnvrtc.dylib";
  38. #else
  39. "libnvrtc.so";
  40. #endif
  41. static const char* default_so_paths[] = {
  42. #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
  43. "nvrtc.dll",
  44. #elif defined(__unix__) || defined(__QNX__) || defined(__APPLE__) || \
  45. defined(__MACOSX)
  46. #if defined(__APPLE__) || defined(__MACOSX)
  47. "/usr/local/cuda/lib/libnvrtc.dylib",
  48. #elif defined(__ANDROID__)
  49. #if defined(__aarch64__)
  50. "/system/vendor/lib64/libnvrtc.so",
  51. #elif defined(__arm__)
  52. "/system/vendor/lib/libnvrtc.so",
  53. #endif
  54. #else
  55. "libnvrtc.so",
  56. // In case some users does not have correct search path configured in
  57. // /etc/ld.so.conf
  58. "/usr/lib/x86_64-linux-gnu/libnvrtc.so",
  59. "/usr/local/nvidia/lib64/libnvrtc.so",
  60. "/usr/local/cuda/lib64/libnvrtc.so",
  61. #endif
  62. #else
  63. #error "Unknown platform"
  64. #endif
  65. };
  66. static const char* extra_so_paths[] = {};
  67. static const char* g_default_api_name = "nvrtc";
  68. #include "./dlopen_helper.h"

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台