用于 CUDA 编程的 GPU 模拟器,无需硬件 [英] GPU Emulator for CUDA programming without the hardware

查看:42
本文介绍了用于 CUDA 编程的 GPU 模拟器,无需硬件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:是否有 Geforce 卡的模拟器可以让我在没有实际硬件的情况下编程和测试 CUDA?

<小时>

信息:

我希望在 CUDA 中加快我的一些模拟,但我的问题是我并不总是在我的桌面上进行这项开发.我想在我的上网本上做一些工作,但我的上网本没有 GPU.现在据我所知,您需要一个支持 CUDA 的 GPU 来运行 CUDA.有没有办法解决这个问题?似乎唯一的方法是使用 GPU 模拟器(这显然会非常缓慢,但可以工作).但无论有什么办法,我都想听听.

我在 Ubuntu 10.04 LTS 上编程.

解决方案

对于那些在2016年(甚至2017年)寻求答案的人...

<小时>

免责声明

  • 毕竟我没能模拟 GPU.
  • 如果您满足其列表,则可以使用 gpuocelot依赖关系.

我已经尝试为 BunsenLabs (Linux 3.16.0-4-686-pae #1 SMPDebian 3.16.7-ckt20-1+deb8u4 (2016-02-29) i686 GNU/Linux).

我会告诉你我学到了什么.

<小时>

  1. nvcc 曾经在 CUDA Toolkit 3.0 中有一个 -deviceemu 选项

    我下载了 CUDA Toolkit 3.0,安装它并尝试运行一个简单的程序:

    #include <stdio.h>__global__ 无效 helloWorld() {printf("Hello world!我是来自 %d 的 %d (Warp %d).
    ",threadIdx.x, threadIdx.x/warpSize, blockIdx.x);}int main() {int 块,线程;scanf("%d%d", &blocks, &threads);helloWorld<<<块,线程>>>();cudaDeviceSynchronize();返回0;}

    请注意,在 CUDA Toolkit 3.0 中,nvcc 位于 /usr/local/cuda/bin/ 中.

    原来我在编译时遇到了困难:

    <块引用>

    注意:此版本不推荐使用设备仿真模式并将在未来的版本中删除./usr/include/i386-linux-gnu/bits/byteswap.h(47):错误:标识符__builtin_bswap32"未定义/usr/include/i386-linux-gnu/bits/byteswap.h(111):错误:标识符__builtin_bswap64"未定义/home/user/Downloads/helloworld.cu(12):错误:标识符cudaDeviceSynchronize"未定义在/tmp/tmpxft_000011c2_00000000-4_helloworld.cpp1.ii"的编译中检测到3个错误.

    我在 Internet 上发现,如果我使用 gcc-4.2 或类似的古老而不是 gcc-4.9.2 错误可能会消失.我放弃了.


  2. gpuocelot

    Stringer 的回答有一个非常古老的 gpuocelot 项目网站的链接.所以一开始我以为这个项目在 2012 年左右就被放弃了.实际上,几年后它就被废弃了.

    以下是一些最新的网站:

    我尝试按照指南安装 gpuocelot.我在安装过程中遇到了几个错误,我又放弃了.gpuocelot 不再受支持,它依赖于一组非常具体的库和软件版本.

    您可以尝试按照本教程 从 2015 年 7 月开始,但我不保证它会起作用.我没有测试过.


  3. MCUDA

    <块引用>

    MCUDA 翻译框架是一个基于 linux 的工具,旨在有效地将 CUDA 编程模型编译为 CPU 架构.

    它可能有用.这是网站链接.


  4. CUDA 浪费

    它是在 Windows 7 和 8 上使用的模拟器.不过我还没有尝试过.它似乎不再开发(最后一次提交日期为 2013 年 7 月 4 日).

    这是项目网站的链接:https://code.google.com/archive/p/cuda-waste/

<小时>

  1. CU2CL

    最后更新:12.03.2017

    正如 dashesy 在评论中指出的那样,CU2CL 似乎是一个有趣的项目.它似乎能够将 CUDA 代码翻译为 OpenCL 代码.因此,如果您的 GPU 能够运行 OpenCL 代码,那么您可能会对 CU2CL 项目感兴趣.

    链接:

Question: Is there an emulator for a Geforce card that would allow me to program and test CUDA without having the actual hardware?


Info:

I'm looking to speed up a few simulations of mine in CUDA, but my problem is that I'm not always around my desktop for doing this development. I would like to do some work on my netbook instead, but my netbook doesn't have a GPU. Now as far as I know, you need a CUDA capable GPU to run CUDA. Is there a way to get around this? It would seem like the only way is a GPU emulator (which obviously would be painfully slow, but would work). But whatever way there is to do this I would like to hear.

I'm programming on Ubuntu 10.04 LTS.

解决方案

For those who are seeking the answer in 2016 (and even 2017) ...


Disclaimer

  • I've failed to emulate GPU after all.
  • It might be possible to use gpuocelot if you satisfy its list of dependencies.

I've tried to get an emulator for BunsenLabs (Linux 3.16.0-4-686-pae #1 SMP Debian 3.16.7-ckt20-1+deb8u4 (2016-02-29) i686 GNU/Linux).

I'll tell you what I've learnt.


  1. nvcc used to have a -deviceemu option back in CUDA Toolkit 3.0

    I downloaded CUDA Toolkit 3.0, installed it and tried to run a simple program:

    #include <stdio.h>
    
    __global__ void helloWorld() {
        printf("Hello world! I am %d (Warp %d) from %d.
    ",
            threadIdx.x, threadIdx.x / warpSize, blockIdx.x);
    }
    
    int main() {
        int blocks, threads;
        scanf("%d%d", &blocks, &threads);
        helloWorld<<<blocks, threads>>>();
        cudaDeviceSynchronize();
        return 0;
    }
    

    Note that in CUDA Toolkit 3.0 nvcc was in the /usr/local/cuda/bin/.

    It turned out that I had difficulties with compiling it:

    NOTE: device emulation mode is deprecated in this release
          and will be removed in a future release.
    
    /usr/include/i386-linux-gnu/bits/byteswap.h(47): error: identifier "__builtin_bswap32" is undefined
    
    /usr/include/i386-linux-gnu/bits/byteswap.h(111): error: identifier "__builtin_bswap64" is undefined
    
    /home/user/Downloads/helloworld.cu(12): error: identifier "cudaDeviceSynchronize" is undefined
    
    3 errors detected in the compilation of "/tmp/tmpxft_000011c2_00000000-4_helloworld.cpp1.ii".
    

    I've found on the Internet that if I used gcc-4.2 or similarly ancient instead of gcc-4.9.2 the errors might disappear. I gave up.


  2. gpuocelot

    The answer by Stringer has a link to a very old gpuocelot project website. So at first I thought that the project was abandoned in 2012 or so. Actually, it was abandoned few years later.

    Here are some up to date websites:

    I tried to install gpuocelot following the guide. I had several errors during installation though and I gave up again. gpuocelot is no longer supported and depends on a set of very specific versions of libraries and software.

    You might try to follow this tutorial from July, 2015 but I don't guarantee it'll work. I've not tested it.


  3. MCUDA

    The MCUDA translation framework is a linux-based tool designed to effectively compile the CUDA programming model to a CPU architecture.

    It might be useful. Here is a link to the website.


  4. CUDA Waste

    It is an emulator to use on Windows 7 and 8. I've not tried it though. It doesn't seem to be developed anymore (the last commit is dated on Jul 4, 2013).

    Here's the link to the project's website: https://code.google.com/archive/p/cuda-waste/


  1. CU2CL

    Last update: 12.03.2017

    As dashesy pointed out in the comments, CU2CL seems to be an interesting project. It seems to be able to translate CUDA code to OpenCL code. So if your GPU is capable of running OpenCL code then the CU2CL project might be of your interest.

    Links:

这篇关于用于 CUDA 编程的 GPU 模拟器,无需硬件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆