OpenCL initialisation problem on Ubuntu 12.04 (NVIDIA GS 7100 card)

Hi, I have a problem with OpenCL on my Ubuntu 12.04 box and a NVIDIA 7100 GS card

I use this very basic source :

#include <CL/cl.h>
#include <CL/cl.hpp>

int main(int argc, char *argv[])
    int err;
    cl_uint platforms;
    cl_platform_id platform = NULL;
    char cBuffer[1024];

    err = clGetPlatformIDs( 1, &platform, &platforms );
    if (err != CL_SUCCESS)
        printf("Error in OpenCL call!
        return EXIT_FAILURE;
    printf("Number of platforms: %d
", platforms);

    err = clGetPlatformInfo( platform, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL );
    if (err != CL_SUCCESS)
        printf("Error in OpenCL call!
        return EXIT_FAILURE;
    printf("CL_PLATFORM_NAME :	 %s
", cBuffer);

    err = clGetPlatformInfo( platform, CL_PLATFORM_VERSION,     sizeof(cBuffer), cBuffer, NULL );
    if (err != CL_SUCCESS)
        printf("Error in OpenCL call!
        return EXIT_FAILURE;
    printf("CL_PLATFORM_VERSION :	 %s
", cBuffer);

And compile it using this makefile :

all : test1

test1 : test1.cpp
    g++ test1.cpp -L/etc/alternatives -lOpenCL -o test1

clean : test1
    rm test1

This compile “fine” (cf. only the CL_USE_DEPRECATED_OPENCL_1_1_APIS warning, but I have a lot of compilations errors without this …)

yannoo@Ubuntoo:~/OPENCL/v2$ make
g++ test1.cpp -L/etc/alternatives -lOpenCL -o test1
In file included from /usr/include/CL/opencl.h:43:0,
                 from /usr/include/CL/cl.hpp:164,
                 from test1.cpp:6:
/usr/include/CL/cl_gl.h:107:2: attention : #warning CL_USE_DEPRECATED_OPENCL_1_1_APIS is defined. These APIs are unsupported and untested in OpenCL 1.2! [-Wcpp]

But when I run the executable, it’s like it cannot find a valid OpenCL context :frowning:

yannoo@Ubuntoo:~/OPENCL/v2$ ./test1
Error in OpenCL call!

=> so the problem is here

err = clGetPlatformIDs( 1, &platform, &platforms );

if (err != CL_SUCCESS)
    printf("Error in OpenCL call!
    return EXIT_FAILURE;

Note that I have the same type of error with another source lesson1.cpp :

#include <utility>

#define __NO_STD_VECTOR // Use cl::vector instead of STL version
#include <CL/cl.h>
#include <CL/cl.hpp>

#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include <iterator>

const std::string hw("Hello World

inline void
checkErr(cl_int err, const char * name)
    if (err != CL_SUCCESS) {
        std::cerr << "ERROR : " << name
                 << " (" << err << ")" << std::endl;

    cl_int err;
    cl::vector< cl::Platform > platformList;
    checkErr(platformList.size()!=0 ? CL_SUCCESS : -1, "cl::Platform::get");
    std::cerr << "Platform number is: " << platformList.size() << std::endl;
    std::string platformVendor;
    platformList[0].getInfo((cl_platform_info)CL_PLATFORM_VENDOR, &platformVendor);
    std::cerr << "Platform is by: " << platformVendor << "
    cl_context_properties cprops[3] = 
        {CL_CONTEXT_PLATFORM, (cl_context_properties)(platformList[0])(), 0};
    cl::Context context(
    checkErr(err, "Conext::Context()");   

 char * outH = new char[hw.length()+1];
    cl::Buffer outCL(
        checkErr(err, "Buffer::Buffer()");

 cl::vector<cl::Device> devices;
    devices = context.getInfo<CL_CONTEXT_DEVICES>();
        devices.size() > 0 ? CL_SUCCESS : -1, "devices.size() > 0");

  std::ifstream file("");
    checkErr(file.is_open() ? CL_SUCCESS:-1, "");
    std::string prog(
    cl::Program::Sources source(
        std::make_pair(prog.c_str(), prog.length()+1));
    cl::Program program(context, source);
    err =,"");
    checkErr(file.is_open() ? CL_SUCCESS : -1, "Program::build()");

cl::Kernel kernel(program, "hello", &err);
    checkErr(err, "Kernel::Kernel()");
    err = kernel.setArg(0, outCL);
    checkErr(err, "Kernel::setArg()");

cl::CommandQueue queue(context, devices[0], 0, &err);
    checkErr(err, "CommandQueue::CommandQueue()");

    cl::Event event;
    err = queue.enqueueNDRangeKernel(
         cl::NDRange(1, 1), 
    checkErr(err, "ComamndQueue::enqueueNDRangeKernel()");

    err = queue.enqueueReadBuffer(
    checkErr(err, "ComamndQueue::enqueueReadBuffer()");
    std::cout << outH;
    return EXIT_SUCCESS;

#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable

__constant char hw[] = "Hello World

__kernel void hello(__global char * out)
    size_t tid = get_global_id(0);
    out[tid] = hw[tid];

Using this makefile :

all : lesson1

lesson1 : lesson1.cpp
    g++ lesson1.cpp -L/etc/alternatives -lOpenCL -o lesson1

clean : lesson1
    rm lesson1

That give at the execution :

yannoo@Ubuntoo:~/OPENCL$ make
g++ lesson1.cpp -L/etc/alternatives -lOpenCL -o lesson1
In file included from /usr/include/CL/opencl.h:43:0,
                 from /usr/include/CL/cl.hpp:164,
                 from lesson1.cpp:6:
/usr/include/CL/cl_gl.h:107:2: attention : #warning CL_USE_DEPRECATED_OPENCL_1_1_APIS is defined. These APIs are unsupported and untested in OpenCL 1.2! [-Wcpp]
yannoo@Ubuntoo:~/OPENCL$ ./lesson1
*ERROR : cl::Platform::get (-1)

And a third code test :

#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#include <CL/cl.h>

int main(void) {

    // Get platform and device information
    cl_platform_id platform_id = NULL;
    cl_device_id device_id = NULL;   
    cl_uint ret_num_devices;
    cl_uint ret_num_platforms;
    cl_int ret;

    ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms);
    printf("plateform_id=%x, ret_num_plareform=%d, ret=%d 
", (int)platform_id, ret_num_platforms, ret); 

    ret = clGetDeviceIDs( platform_id, CL_DEVICE_TYPE_DEFAULT, 1, &device_id, &ret_num_devices);
   printf("platform_id=%x, device_id=%x , ret_num_devices=%x, ret=%d 
", (int)platform_id, (int)device_id, ret_num_devices, ret);


That give at execution :

plateform_id=0, ret_num_plareform=0, ret=-1001 
platform_id=0, device_id=0 , ret_num_devices=1, ret=-32

My graphic card is not compatible with OpenCL or it’s another thing ?

yannoo@Ubuntoo:~/OPENCL$ lspci | grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation NV44 [GeForce 7100 GS] (rev a1)

Geforce 7 is too old. General purpose compute capability started with GeForce 8 IIRC:

Thank for the link, Dark Photon

=> this seem to me a valid reason “to invest” into a new graphic card in the beginning of the last year :slight_smile:

But why standards OpenCL funcs cannot to be emulated on “olds” cards like this is make since the beginning in OpenGL ?
(only the core funcs, not the very hardware/vendor specifics/extended funcs of course)

Not an expert here, but IIRC Pre SM-4.0 cards such as GeForce 7 and earlier didn’t have unified stream processors (read: lots of fixed function hardware) which made it problematic to implement the GPGPU-type functionality needed for CUDA, OpenCL, Compute shaders, etc.

As an aside, what CPU do you have? Judging from your setup code, you don’t seem to have one of those either, right?

Thanks for your response, Dark Photon

This effectively seem a good reason for not to have a too negative accelleration because the need to using a software emulation on “old” hardware :slight_smile:

Thokra, it’s a Pentium 4 3.06 Ghz
(ok, it’s certainly now very far from the best CPU but I don’t think that it can be view as a really too old computer)
[on other side, I see at that the Intel i7 @3.47 GHz have 6933.79 bogomips on each core where cpuinfo say 6111.98 bogomips on each core on the mine … but ok with 12 core on the i7 vs only two for my P4 @3.06 GHz :slight_smile: => my CPU can now really to be considered as too old ?]

And isn’t the GeForce GS 7100 (nv44) a true GeForce 7 card ???
(I have take a look at and and seen that my card is relatively old, something like 2006/2007)

==> I really need a more recent graphic card :slight_smile:
(and perhaps a newer CPU/computer but I don’t have planned to buy a newer computer in the near future)

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.