I removed the file nvidia.icd from /etc/OpenCL/vendors/ and then i tried the above mentioned command 
*echo libnvidia-opencl.so.1 >> /etc/OpenCL/vendors/nvidia.icd*

and it worked. but i still get the same error when running following code:

import pyopencl as cl

clGetPlatformIDs failed: <unknown error -1001>

On Sun, Mar 11, 2018 at 4:58 PM, aseem hegshetye <aseem.hegshetye@gmail.com> wrote:
I was able to log in as root user by doing "sudo -i" after ssh to the aws ec2 instance. 

but now the command *echo libnvidia-opencl.so.1 >> /etc/OpenCL/vendors/nvidia.icd* says 

"    -bash: /etc/OpenCL/vendors/nvidia.icd: No such file or directory"

On Sun, Mar 11, 2018 at 5:51 AM, aseem hegshetye <aseem.hegshetye@gmail.com> wrote:
is there a way around to solve this without being a root user?

On Sun, Mar 11, 2018 at 1:34 AM, Andreas Kloeckner <lists@informa.tiker.net> wrote:
aseem hegshetye <aseem.hegshetye@gmail.com> writes:

> Hi,
> I get this error when i run following code:
> *import pyopencl as cl*
> *cl.get_platforms()*
>  I tried following command in ubuntu terminal to fix it:
>  * sudo echo e- 'echo libnvidia-opencl.so.1'  >>
> /etc/OpenCL/vendors/nvidia.icd*
>  and
> *echo libnvidia-opencl.so.1 >> /etc/OpenCL/vendors/nvidia.icd*
>  But i get permission denied error.

Only writable as root.