# cudamallochost problem

**URL:** <https://forums.developer.nvidia.com/t/cudamallochost-problem/21428>\
**Category:** CUDA Programming and Performance\
**Created:** [March 9, 2011, 8:18am UTC](https://forums.developer.nvidia.com/t/cudamallochost-problem/21428 "2011-03-09T08:18:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpl](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@cpl](https://forums.developer.nvidia.com/u/cpl)\
**Post date:** [March 9, 2011, 8:18am UTC](https://forums.developer.nvidia.com/t/cudamallochost-problem/21428/1 "2011-03-09T08:18:21Z")

</div>

Hi all,  
I just started programming in Cuda. Right now I’m trying to recompile a free software from the internet. It compiles fine, but when I run it, I immediately get an error. The error is caused by a call to cudaMallocHost, which is trying to allocate 28 MB. I get an cuda unknown error. After searching online I tried to check if an error was set just before the call, and it was not. I then tried to lower the amount of memory, and I managed to make it work only when I allocated few thousand of bytes. The PC i’m working on is an i7 with 6 GB of RAM, so it should not be out of memory. Is there anything I can try to make it work?  
Thanks

---

<div class="post-metadata">

**Author:** ![cpl](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@cpl](https://forums.developer.nvidia.com/u/cpl)\
**Post date:** [March 9, 2011, 8:31am UTC](https://forums.developer.nvidia.com/t/cudamallochost-problem/21428/2 "2011-03-09T08:31:36Z")

</div>

PS: I tried using CudaAllocHost with the same results…

---

<div class="post-metadata">

**Author:** ![huangshuojch](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@huangshuojch](https://forums.developer.nvidia.com/u/huangshuojch)\
**Post date:** [March 9, 2011, 3:46pm UTC](https://forums.developer.nvidia.com/t/cudamallochost-problem/21428/3 "2011-03-09T15:46:54Z")

</div>

Can you tell us the specific information of error ?

---

<div class="post-metadata">

**Author:** ![cpl](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@cpl](https://forums.developer.nvidia.com/u/cpl)\
**Post date:** [March 9, 2011, 3:58pm UTC](https://forums.developer.nvidia.com/t/cudamallochost-problem/21428/4 "2011-03-09T15:58:42Z")

</div>

I don’t have any specific information on the error, since the cudaSafeCall returns unknown error, and cudaGetErrorString too.

---

<div class="post-metadata">

**Author:** ![colede](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@colede](https://forums.developer.nvidia.com/u/colede)\
**Post date:** [March 9, 2011, 7:12pm UTC](https://forums.developer.nvidia.com/t/cudamallochost-problem/21428/5 "2011-03-09T19:12:28Z")

</div>

Post your code that is doing the allocating

---

<div class="post-metadata">

**Author:** ![cpl](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@cpl](https://forums.developer.nvidia.com/u/cpl)\
**Post date:** [March 10, 2011, 9:00am UTC](https://forums.developer.nvidia.com/t/cudamallochost-problem/21428/6 "2011-03-10T09:00:41Z")

</div>

I’m trying to compile the CUJ2K program, you can find it here: [http://cuj2k.sourceforge.net/](http://cuj2k.sourceforge.net/). The problem shows up in the bmp-read.cu file, around line 305-310 (I changed the code a bit so I’m not sure about the exact line number). If you want to try and compile it, you should change a bit the code. In particular in file device.cu, line 167, you should change the line that checks the cuda version to

if( major \>1 || (major == 1 && minor \>= 1))

otherwise if you have a rather new video card (i.e. cuda 2.0 or later) it won’t run complaining your card does not support the cuda version.

---

<div class="post-metadata">

**Author:** ![cpl](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@cpl](https://forums.developer.nvidia.com/u/cpl)\
**Post date:** [March 10, 2011, 9:05am UTC](https://forums.developer.nvidia.com/t/cudamallochost-problem/21428/7 "2011-03-10T09:05:51Z")

</div>

PS: actually also the code right above that line in device.cu should be changed, but it won’t be a problem if you have only one nvidia video card in your system
