# Is it possible to create a virtual environment using CUDA?

**URL:** https://discourse.julialang.org/t/is-it-possible-to-create-a-virtual-environment-using-cuda/84185
**Category:** General Usage
**Tags:** gpu, cudanative, cuda
**Created:** [July 13, 2022, 4:01pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-virtual-environment-using-cuda/84185 "2022-07-13T16:01:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Fathya.Salih](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@Fathya.Salih](https://discourse.julialang.org/u/Fathya.Salih)
#### Post date: [July 13, 2022, 4:01pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-virtual-environment-using-cuda/84185/1 "2022-07-13T16:01:05Z")

</div>

Hello!

I am trying to use julia 1.2.0 on a remote GPU system and I am having trouble creating a virtual environment where I can add the packages I need. These are the packages available in the remote machine:

```julia
(v1.2) pkg> status
    Status `/usr/local/share/julia/environments/v1.2/Project.toml`
  [3895d2a7] CUDAapi v1.2.0
  [c5f51814] CUDAdrv v4.0.2
  [be33ccc6] CUDAnative v2.5.1
  [3a865a2d] CuArrays v1.4.1

```

I don’t have admin privileges to add or update packages, but I’m assuming I can do that in a virtual environment.

All the tutorials I’ve found on creating virtual environments require adding a package like Playground.jl or VirtualEnv.jl. Is it possible to create a virtual environment using the versions of CUDA I have listed above?

Any advice or thoughts are welcomed!

---

<div class="post-metadata">

### Author: ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)
#### Post date: [July 13, 2022, 4:33pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-virtual-environment-using-cuda/84185/2 "2022-07-13T16:33:42Z")

</div>

First, is there any particular reason you’re stuck using Julia v1.2? That’s several years old at this point and basically unsupported - the current long-term support version is v1.6. Using an old version of Julia also prevents you from using modern versions of Julia’s CUDA stack - I’d highly recommend upgrading to at least Julia v1.6.

Julia’s built-in package manager supports [environments](https://pkgdocs.julialang.org/v1/environments/) by default, so you shouldn’t need any external package. Briefly:

```julia
julia> cd(mktempdir())

(@v1.8) pkg> activate CUDATestProject # enter Pkg mode with the ] key
  Activating new project at `C:\Users\alexa\AppData\Local\Temp\jl_gcrbSw\CUDATestProject`

(CUDATestProject) pkg> add CUDA
    Updating registry at `C:\Users\alexa\.julia\registries\General.toml`
   Resolving package versions...
   Installed GPUArraysCore ─ v0.1.0
[...]

julia> using CUDA

julia> @time sum(CUDA.rand(10^8)) # CUDA is downloaded at time of first use
  Downloaded artifact: CUDA
145.488497 seconds (30.93 M allocations: 2.484 GiB, 0.50% gc time, 4.94% compilation time)
5.000604f7

julia> @time sum(CUDA.rand(10^8))
  0.093087 seconds (145 allocations: 7.844 KiB)
4.9994404f7

```

---

<div class="post-metadata">

### Author: ![Fathya.Salih](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@Fathya.Salih](https://discourse.julialang.org/u/Fathya.Salih)
#### Post date: [July 19, 2022, 1:08pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-virtual-environment-using-cuda/84185/3 "2022-07-19T13:08:34Z")

</div>

Unfortunately, I am stuck with julia v1.2.0 for now. I’ll ask our IT if they can update their julia version. But your suggestion worked for me. Many thanks!

```julia
julia> mktempdir(tempdir())
"/tmp/jl_SXNP1z"

(v1.2) pkg> activate CUDATestProject
Activating new environment at `~/CUDATestProject/Project.toml`

(CUDATestProject) pkg> add BenchmarkTools
 Resolving package versions...
  Updating `~/CUDATestProject/Project.toml`
  [6e4b80f9] + BenchmarkTools v0.4.3
  Updating `~/CUDATestProject/Manifest.toml`
  [6e4b80f9] + BenchmarkTools v0.4.3
  [682c06a0] + JSON v0.21.0
  [69de0a69] + Parsers v0.3.8
  [2a0f44e3] + Base64
  [ade2ca70] + Dates
  [8ba89e20] + Distributed
  [b77e0a4c] + InteractiveUtils
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [56ddb016] + Logging
  [d6f4376e] + Markdown
  [a63ad114] + Mmap
  [de0858da] + Printf
  [9a3f8284] + Random
  [9e88b42a] + Serialization
  [6462fe0b] + Sockets
  [2f01184e] + SparseArrays
  [10745b16] + Statistics
  [8dfed614] + Test
  [4ec0a83e] + Unicode

```

---

<div class="post-metadata">

### Author: ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)
#### Post date: [July 19, 2022, 3:25pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-virtual-environment-using-cuda/84185/4 "2022-07-19T15:25:03Z")

</div>

> [@Fathya.Salih](#):
>
> I’ll ask our IT if they can update their julia version.

You can just download and extract an archive containing Julia to your home folder or wherever, it doesn’t need any installation.
