question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cupy.random.bytes not working

See original GitHub issue
  • Conditions (you can just paste the output of python -c 'import cupy; cupy.show_config()')
OS                           : Linux-5.9.8-2-MANJARO-x86_64-with-arch-Manjaro-Linux
CuPy Version                 : 8.1.0
NumPy Version                : 1.19.4
SciPy Version                : 1.5.3
CUDA Root                    : /[hiden]/.conda/envs/rapids-0.16
CUDA Build Version           : 10010
CUDA Driver Version          : 11010
CUDA Runtime Version         : 10010
cuBLAS Version               : 10201
cuFFT Version                : 10101
cuRAND Version               : 10101
cuSOLVER Version             : (10, 2, 0)
cuSPARSE Version             : 10300
NVRTC Version                : (10, 1)
Thrust Version               : 100906
CUB Build Version            : 100800
cuDNN Build Version          : None
cuDNN Version                : None
NCCL Build Version           : 2708
NCCL Runtime Version         : 2708
cuTENSOR Version             : None
Device 0 Name                : GeForce GTX 1080 Ti
Device 0 Compute Capability  : 61
  • Code to reproduce
import cupy as cp
b = cp.random.bytes(10)
  • Error messages, stack traces, or logs
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-121-104e7c75af44> in <module>
      1 import cupy as cp
----> 2 b = cp.random.bytes(10)

~/.conda/envs/rapids-0.16/lib/python3.7/site-packages/cupy/random/__init__.py in bytes(length)
      8                  <numpy.random.mtrand.RandomState.bytes>`
      9     """
---> 10     return _numpy.bytes(length)
     11 
     12 

~/.conda/envs/rapids-0.16/lib/python3.7/site-packages/numpy/__init__.py in __getattr__(attr)
    213             else:
    214                 raise AttributeError("module {!r} has no attribute "
--> 215                                      "{!r}".format(__name__, attr))
    216 
    217         def __dir__():

AttributeError: module 'numpy' has no attribute 'bytes'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lucasrodescommented, Nov 24, 2020

Thanks for your hints, @kmaehashi, really appreciate it. While trying this I ran into an error. I opened issue #4321

1reaction
kmaehashicommented, Nov 24, 2020

Thanks for sharing the details of your use-case @lucasrodes! In your case, I think it’s better to generate and handle data as a sequence of uint8 instead of bytes.

N = 10
L = 8
data = numpy.random.randint(0,256, size=(N, L), dtype=numpy.uint8)  # or cupy instead of numpy

As for hash functions, you will need to write or find the CUDA implementation like this one, load it using cupy.RawKernel and pass the generated random array to it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cupy.random.bytes — CuPy 11.4.0 documentation
Returns random bytes. Note. This function is just a wrapper for numpy.random.bytes . The resulting bytes are generated on the host (NumPy), not...
Read more >
cupy.random.seed — CuPy 11.4.0 documentation
This function resets the state of the global random number generator for the current device. Be careful that generators for other devices are...
Read more >
cupy.load — CuPy 11.4.0 documentation
If pickles are disallowed, loading object arrays will fail. Please be aware that CuPy does not support arrays with dtype of object ....
Read more >
Random sampling (cupy.random) — CuPy 11.4.0 ...
Most functions under cupy.random support the dtype option, which do not exist in the corresponding NumPy APIs. ... bytes (length). Returns random bytes....
Read more >
CuPy Documentation - Read the Docs
Note: If you encounter any problem with CuPy installed from ... NumPy allocates 400 bytes in CPU (not managed by CuPy memory pool)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found