如果 X11 像这样在 GPU 上运行:
Fri Aug 2 23:52:39 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 430.30 Driver Version: 430.30 CUDA Version: 10.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla M60 Off | 00000000:00:1E.0 Off | 0 |
| N/A 28C P8 14W / 150W | 141MiB / 7618MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 3255 G /usr/lib/xorg/Xorg 57MiB |
| 0 3286 G /usr/bin/gnome-shell 81MiB |
+-----------------------------------------------------------------------------+
如果您运行 XShmGetImage(),它会给您一个指向 GPU 内存或主机内存中的内存地址的指针吗?
如果是 GPU,我假设您可以用它在 NVIDIA 卡上执行其他操作,例如 H264 编码该数据。
有没有办法将内存从一个 GPU 内存块复制到另一个 GPU 内存块?
我正在使用 NVENC 库。
最佳答案
阅读MIT Shared Memory extension's文档:
The next step is to create the shared memory segment. This is best done after the creation of the XImage, since you need to make use of the information in that XImage to know how much memory to allocate. To create the segment, you need a call like:
shminfo.shmid = shmget(IPC_PRIVATE, image->bytes_per_line * image->height, IPC_CREAT|0777);
这意味着扩展将“共享内存”视为“由 shmget
或等效项返回的内容”。自 shmget
is incapable of allocating GPU memory ,我的回答是 XImage 在主机内存中,而不是设备。
关于c++ - 在 GPU 上使用 X11 时,XShmGetImage 是否会返回主机/设备内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57334841/