How do I enable multiple cores in my virtual enviroment?
I've installed Ubuntu in a virtual environment using Oracle VM VirtualBox Manager and it works great.
However I'd like to enable multiple cores - as seen in the image below my Windows machine has 2 cores:
Now when I run the lscpu
in Ubuntu I get the following info revealing that only 1 core is being utilized:
I've tried changing the settings of the virtual box to enable multiple processors but it won't allow me to do so as shown in the image below:
How do I enable multiple cores (processors) in my virtual enviroment?
Solution 1:
To enable more than 1 CPU in your VM the following settings are needed in addition:
-
64-bit virtual guest hardware in General settings tab (for 64-bit guests)
-
enable I/O APIC in the Motherboard settings tab
-
enable hardware virtualization (VT-x/AMD-V) in the Acceleration tab
Note that if your run your VM on all cores available you may experience a better host performance when assigning an execution cap to the CPU.
If you had not enabled hot-plug CPU feature of virtualbox changing of the number of cores can only be done on a machine that was shut down.
A performance boost in the guest is only to be expected for software that makes use of several cores. Only then giving all cores with an execution cap makes sense.
Solution 2:
If your VM is currently running (or "Saved") you can't change that value. Power off your VM first.
Solution 3:
I was working on a multithreaded program which executed in sequential order on virtual machine. I had similar problem as you had. I fixed it by :
- Stop virtual machine or exit.
- Launch VMWare --> Select machine -->Click System --> Click Processor --> Change number processors.
- Start Virtual Machine.
Earlier std::thread::hardware_concurrency() from standard thread returned 1, but, after changes it returns the number of CPU's on the settings of Virtual Machine.
Now, I was able to run my multithreaded programs on VM successfully.