小编Tou*_*Liu的帖子

CuPy 不适用于 Ubuntu 18.04 和 CUDA 9.0

状况:

  • CuPy 版本 7.0.0
  • 操作系统/平台 Ubuntu 18.04
  • CUDA 9.0 版
  • cuDNN/NCCL 7.6.5 版(适用于 cuda 9.0)
  • GPU 英伟达 GTX580
  • 驱动程序版本 390.116

代码 1:

import cupy as cp
x = cp.arange(6).reshape(2, 3).astype('f')
Run Code Online (Sandbox Code Playgroud)

错误信息 1:

NVRTC compilation error: nvrtc: error: invalid value for --gpu-architecture (-arch)

-----
Name:
Options: -I/home/liu/.local/lib/python2.7/site-packages/cupy/core/include -I /usr/local/cuda-9.0/include -ftz=true -arch=compute_20
CUDA source:
1
-----
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/liu/.local/lib/python2.7/site-packages/cupy/creation/ranges.py", line 57, in arange
    _arange_ufunc(typ(start), typ(step), ret, dtype=dtype)
  File "cupy/core/_kernel.pyx", line 864, in …
Run Code Online (Sandbox Code Playgroud)

python cuda cupy

2
推荐指数
1
解决办法
610
查看次数

当剂量移动构造函数和默认构造函数被调用时

我有这个代码

class MyString {
    public:
        MyString();
        MyString(const char*);
        MyString(const String&);
        MyString(String&&) noexcept;
        ...
};

String::String()
{
    std::cout << "default construct!" <<std::endl;
}

String::String(const char* cb)
{
    std::cout << "construct with C-char!" <<std::endl;
    ...
}


String::String(const String& str)
{
    std::cout << "copy construct!" <<std::endl;
    ...
}

String::String(String&& str) noexcept
{
    std::cout << "move construct!" <<std::endl;
    ...
}

Run Code Online (Sandbox Code Playgroud)

在main()

MyString s1(MyString("test"));
Run Code Online (Sandbox Code Playgroud)

我以为结果会是这样的:

用 C-char 构建!<---- 由 MyString("test")
移动构造调用!<---- 由 s1(...) 调用

但我得到的是这样的:

用 C-char 构建!<---- 可能由 MyString() 调用

我想到的步骤

  1. MyString("test")使用构造函数来构造右值 …

c++ constructor c++11

0
推荐指数
1
解决办法
132
查看次数

标签 统计

c++ ×1

c++11 ×1

constructor ×1

cuda ×1

cupy ×1

python ×1