2024年3月14日发(作者:)
本文档介绍如何在Unbuntu9.04安装cudatoolkit2.3+cudasdk2.3+gpgpu-sim2.1.1b并编译
运行ispass2009的benchmarks< xmlnamespace prefix ="o" ns
="urn:schemas-microsoft-com:office:office" />
注:本文档主要依据gpgpu-sim自带的GPGPU-SIM Manual Version 1.0
Compiling GPGPU-Sim
* Step 1: Ensure you have gcc, make, zlib, bison and flex installed on your system.
For CUDA 2.x we used gcc version 4.3.2, for CUDA 1.1 we used gcc version 4.1.3. We
used bison version 2.3, and flex version 2.5.33.
* To use OpenCL: An installation of NVIDIA OpenCL drivers from NVIDIA's
OpenCL Page.
* GNU Compiler Collection (i.e. gcc) 4.0 or newer
o gcc 4.3 recommended for CUDA 2.x
o gcc 4.1 recommended for CUDA 1.1
* bison (version 2.3 recommended)
apt-get install bison
.
* flex (version 2.5.33 recommended)
apt-get install flex
* zlib
* The benchmarks from the ISPASS 2009 paper (distributed separately) have
additional dependencies.
1.已有
* Step 2: Download and install the CUDA Toolkit and CUDA SDK code samples from
NVIDIA's website: /cuda. If you want to run OpenCL on the
simulator, download and install NVIDIA's OpenCL driver from
/object/.
* An installation of CUDA which you need to download from NVIDIA's website.
ad cudatoolkit_2.3_linux_32_ from
/cuda-downloads.
2.给cudatoolkit_2.3_linux_32_添加执行权限:
chmod +x cudatoolkit_2.3_linux_32_
3.运行
sudo ./cudatoolkit_2.3_linux_32_
设置路径为default即可
4.上述安装了cudatoolkit,还要安装cudasdk,下载cudasdk_
+x cudasdk_2.3_
./cudasdk_2.3_ 设置路径为default即可
* Step 3: Build libcutil.a. The install script for the CUDA SDK does not do this
step automatically. If you installed the CUDA Toolkit in a nonstandard location you
will first need to set CUDA_INSTALL_PATH to the location you installed the CUDA
toolkit (including the trailing "/cuda"). Then, change to the C/common subdirectory
of your CUDA SDK installation (or common subdirectory on older CUDA SDK versions)
and type "make".
cd /home/test/ NVIDIA_GPU_Computing_SDK/C/commom
make
* Step 4: Set environment variables (e.g., your .bashrc file if you use bash
as your shell).
打开.bashrc文件
gedit ~/.bashrc
o (a) Set GPGPUSIM_ROOT to point to the directory containing this README
file.
在文件最后添加
export
GPGPUSIM_ROOT="/home/intel/Downloads/Graphics/Simulation/GPGPU-Sim/gpgpu-sim_v2
.1.1b" (用绝对路径)
o (b) Set CUDAHOME to point to your CUDA installation directory
继续添加
export CUDAHOME="/usr/local/cuda"
o (c) Set NVIDIA_CUDA_SDK_LOCATION to point to the location of the CUDA
SDK
继续添加
export
NVIDIA_CUDA_SDK_LOCATION="/home/intel/NVIDIA_GPU_Computing_SDK"
o (d) Add $CUDAHOME/bin and $GPGPUSIM_ROOT/bin to your PATH
继续添加
export PATH="$PATH:$CUDAHOME/bin:$GPGPUSIM_ROOT/bin"
o (e) Add $GPGPUSIM_ROOT/lib/ to your LD_LIBRARY_PATH and remove
$CUDAHOME/lib or $CUDAHOME/lib64 from LD_LIBRARY_PATH
继续添加
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GPGPUSIM_ROOT/lib/" (把
LD_LIBRARY_PATH设置为gpgpusim的库文件,这样cuda程序会链接到gpgpusim运行。相
反,如果想要重新使用显卡运行cuda程序,把$GPGPUSIM_ROOT/lib/从LD_LIBRARY_PATH
里去掉即可)
o (f) If using OpenCL, set NVOPENCL_LIBDIR to the installation directory
of distributed with the NVIDIA OpenCL driver. On SuSe 11.1 64-bit
NVIDIA's is installed in /usr/lib64/.
Not done.
注意,修改完.bashrc文件后需要重启gnome-terminal
* Step 5: Type "make" in this directory. This will build the simulator with
optimizations enabled so the simulator runs faster. If you want to run the simulator
in gdb to debug it, then build it using "make DEBUG=1" instead.
问题1:如果出现include
解决: 下载最新的mesa-commom-dev包
(mesa-commom-dev_7.7.1-1ubuntu3_)
sudo dpkg -i mesa-commom-dev_7.7.1-1ubuntu3_
按照依赖关系下载依赖包并安装(libdrm-dev_2.4.18-1unbuntu3_)解决
问题;
至此,该问题pass。
问题2::1506: error: invalid conversion from ‘const char*’ to
‘char*
解决:这是gcc4.4更加严格的语法造成的,在有些gcc版本只会出现warning,不
会出现error,在/gcc-4.4/porting_中有更详细的解释,解
决方法很简单,在
char *tmp = strstr(de->d_name,".ptx");前面加上 const,问题解决。
问题3:继续出现问题
: In member function ‘virtual void Stats::Display()
const’:
:96: error: ‘printf’ was not declared in this scope
:104: error: ‘printf’ was not declared in this scope
以及:44: error: ‘printf’ was not declared in this scope
解决:在相应文件头添加
#include
问题4:继续出现问题 /usr/bin/ld: cannot find -lGL
解决:属于链接异常,以下资料来自网上((通常在软件编译时出现的usr/bin/ld:
cannot find -lxxx的错误,主要的原因是库文件并没有导入的ld检索目录中
解决方式:
1。确认库文件是否存在,比如-l123, 在/usr/lib, /usr/local/lib,或者其他自
定义的lib下有无, 如果只是存在.1,那么可以通过ln -sv
.1 ,建立一个连接重建.
2。检查/etc/中的库文件路径是否正确,如果库文件不是使用系统路
径,/usr/lib, /usr/local/lib, 那么必须在文件中加入。
3。ldconfig 重建文件,ld的库文件检索目录存放文件。尤其刚刚
编译安装的软件,必须运行ldconfig,才能将新安装的
库文件导入.
4。测试,gcc -l123 --verbose.))
在本例中,实际上是因为在/usr/lib中没有造成的,可以在
/中搜索即可搜到libgl1-mesa-dev,下载
libgl1-mesa-dev_7.7.1-1unbuntu3_(这里的unbuntu3需要与之前使用的
mesa-common-dev)的版本一致,否则会安装不上。使用命令
sudo dpkg -i libgl1-mesa-dev_7.7.1-1ubuntu2_
安装完成。
重新make,成功。
*Step 6: Run a CUDA built with a recent version of CUDA (or an OpenCL application)
and the device code should now run on the simulator instead of your graphics card.
To be able to run the application on your graphics card again, remove
$GPGPUSIM_ROOT/lib from your LD_LIBRARY_PATH. See also Statically (Compile Time)
Linking GPGPU-Sim.
* NOTES: Step 5 will build the libraries that contain GPGPU-Sim. These libraries
can be linked to a CUDA application dynamically or at compile time, creating an
executable that runs the CUDA application on GPGPU-Sim rather than a GPU.
o The following shared libraries are used with prebuilt CUDA/OpenCL
applications generated with a recent version of CUDA (2.1 or newer). See Dynamically
Linking with GPGPU-Sim for more details.
+ lib/ - For prebuilt CUDA applications
+ lib/ - For prebuild OpenCL applications
o The following files are created to be used when building an application
with statically linked libraries. See Statically (Compile Time) Linking GPGPU-Sim
for more details.
+ src/libgpgpusim.a - Performance simulator module of GPGPU-Sim
+ src/cuda-sim/libgpgpu_ptx_sim.a - Functional simulator module of
GPGPU-Sim
+ src/intersim/libintersim.a - Interconnection simulator module of
GPGPU-Sim (derived from Book-Sim)
+ lib/libcuda.a - CUDA API stub library that interface GPGPU-Sim
with a CUDA application
运行CUDA程序例子,来自其benchmark中的AES:
cd $GPGPUSIM_ROOT/benchmarks/CUDA/AES/
make
1.该程序要求预先安装boost库
apt-get install libboost-regex-dev,该问题pass
重新make,如果出现问题:34:19: error: cutil.h: No such file or
directory
解决:You may want to first check if NVIDIA_CUDA_SDK_LOCATION is set to the
correct location. Notice that CUDA SDK 2.0 and onwards have moved the common
libraries from $NVIDIA_CUDA_SDK_LOCATION/common/lib to
$NVIDIA_CUDA_SDK_LOCATION/C/common/lib. So you may want to change the
that comes with GPGPU-Sim to make sure it matches with your CUDA SDK version. If
that path is properly set and you are still getting the error. Chances are you have
not compile libcutil.a. You can do that by running make at
$NVIDIA_CUDA_SDK_LOCATION/C/common.
重新make,出现很多类似的问题error: inline function ‘int __signbit(double)’
cannot be declared weak
解决:这个也是gcc4.4.*版本的问题,在Nvidia的forum上已经有人讨论过,其来
源是因为
# CUDA is NOT made for GCC version greater than 4.3
# Ubuntu/Kubuntu 9.10 Jaunty is NOT officially supported
可以如下解决
To compile the examples with gcc 4.4 i have had to comment the following three
lines in /usr/local/cuda/include/math_functions.h
extern __host__ __device__ int __signbit(double) __THROW;
extern __host__ __device__ int __signbitf(float) __THROW;
extern __host__ __device__ int __signbitl(long double) __THROW;
and two lines in /usr/local/cuda/include/common_functions.h
extern __host__ __device__ void *memset(void *s, int c, size_t n) __THROW;
extern __host__ __device__ void *memcpy(void *d, const void *s, size_t n)
__THROW;
这个问题可以暂时解决,据说在后面的FluxGL程序还会碰到其他问题。
重新make,继续出现问题/usr/bin/ld: cannot find --lboost_filesystem
说明之前boost库安装不完全,还缺少库,对于 /usr/bin/ld: cannot find -lxxx这
种问题的一种统一方法是apt-get install libxxx-dev,对于本例为
sudo apt-get install libboost-filesystem-dev
重新make,成功。
运行benchnmark AES:
./gpgpu_ptx_sim__aescuda e 128 ./data/ ./data/
如果运行出现问题
GPGPU-Sim ** ERROR: Cannot open config file ''
解决:需要用到gpgpu-sim_v2.1.1b/configs/QuadroFX5800目录下的两个文件
和icnt_config_quadro_。转到
gpgpu-sim_v2.1.1b/benchmarks/目录下,运行
./setup_ ../configs/QuadroFX5800
这个脚本会自动把上述两个文件链接到每一个测试程序下
如果运行继续出现出现问题
Assertion “gpgpu_cuda_sim”failed
解决:chmod +w
gedit
设置参数 –gpgpu_cuda_sim 为 1
如果运行继续出现出现问题
gedit
设置参数 –gpgpu_ptx_sim_mode 为 1
至此./gpgpu_ptx_sim__aescuda e 128 ./data/ ./data/可以
运行成功.
注意:编译和运行其他benchmarks请参考每个benchmark目录下的-Sim
文件


发布评论