Yes, you should apply for a job right away.
It's not unusual to take a few months to find a job that suits you, take advantage of this time period.
Applying just before you graduate or right after graduation is too late, it will most likely result in a few months with no paychecks or you'll settle for a less-interesting job just because you really need it.
There's nothing wrong with applying for jobs while not being available, just make sure to bring it up in every interview that you're not free until you've graduated in X months, companies will not look down on you for wasting their time, it's not a waste at all to get to know you too early when it could have been too late.
I graduated in June last year but I started applying in January, the time period gave me 3 job offers and roughly 4 times as many interviews, one of which I accepted roughly a month and a half before I graduated. I took one week off after the graduation and then started working for the company.
Some students waited with the applying part until a month before graduation, in many cases it lead to stress, unemployment for a while after graduation and so on.
Worst case scenario: The company needs someone right away (so you wouldn't have missed anything by waiting anyway, no harm!) and you get experience from the interview. They might even keep your resume for future job openings.
Best case scenario: You get a job offer you like within a decent time period, giving you time to focus on your graduation.
Good luck.