Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8865711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:35:01+00:00 2026-06-14T16:35:01+00:00

I made a very simple kernel below to practice CUDA. import pycuda.driver as cuda

  • 0

I made a very simple kernel below to practice CUDA.

import pycuda.driver as cuda
import pycuda.autoinit
import numpy as np
from pycuda.compiler import SourceModule
from pycuda import gpuarray
import cv2

def compile_kernel(kernel_code, kernel_name):
  mod = SourceModule(kernel_code)
  func = mod.get_function(kernel_name)
  return func

input_file = np.array(cv2.imread('clouds.jpg'))
height, width, channels = np.int32(input_file.shape)

my_kernel_code = """
  __global__ void my_kernel(int width, int height) {
    // This kernel trivially does nothing! Hurray!
  }
"""
kernel = compile_kernel(my_kernel_code, 'my_kernel')

if __name__ == '__main__':

  for i in range(0, 2):
    print 'o'
    kernel(width, height, block=(32, 32, 1), grid=(125, 71))

    # When I take this line away, the error goes bye bye.
    # What in the world?
    width -= 1

Right now, if we run the code above, execution proceeds through the first iteration of the for loop just fine. However, during the second iteration of the loop, I get the following error.

Traceback (most recent call last):
  File "outOfResources.py", line 27, in <module>
    kernel(width, height, block=(32, 32, 1), grid=(125, 71))
  File "/software/linux/x86_64/epd-7.3-1-pycuda/lib/python2.7/site-packages/pycuda-2012.1-py2.7-linux-x86_64.egg/pycuda/driver.py", line 374, in function_call
    func._launch_kernel(grid, block, arg_buf, shared, None)
pycuda._driver.LaunchError: cuLaunchKernel failed: launch out of resources

If I take away the line width -= 1, the error goes away. Why is that? Can’t I change the parameter for a kernel the second time around? For reference, here is clouds.jpg.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:35:03+00:00Added an answer on June 14, 2026 at 4:35 pm

    Though the error message isn’t particularly informative, note that you need to pass in a correctly casted width variable. So something like:

    width = np.int32(width - 1)
    

    should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently made a very simple practice program in Python, that takes user input
I'm working with Cocos2D and I've made a very simple class that inherits from
So I made a very simple program that counts down from 99 (sings 99
I just made a very simple test app using documentation from MSDN. All I
I made a very simple application to store variables that can be edited onto
So I made this (very simple) program with a swing GUI with NetBeans, and
I've made a very simple aspect, and found a problem when debugging it (see
I've made a very simple REST controller method with Spring 3.0.0.RC1 that uses hibernate
I have made a very simple AppleScript to close tabs in Safari. The problem
in my application I made a very simple binding. I have a NSMutableArray bound

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.